:root {
  --bg: #14161a;
  --panel: #1d2027;
  --line: #2c313b;
  --text: #e8eaed;
  --muted: #949cab;
  --accent: #c8a96a;
  --danger: #d96060;
  --ok: #5fb37a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  padding: 16px 16px 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h1 { font-size: 18px; margin: 0; color: var(--accent); }
.who { color: var(--muted); font-size: 13px; }

nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

nav button {
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

nav button.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

main { padding: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.grow { flex: 1 1 220px; min-width: 0; }

h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); }

.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.big { font-size: 22px; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }

.top-card { margin-top: 18px; }

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.stat .label { color: var(--muted); font-size: 12px; }

input, textarea, select {
  width: 100%;
  background: #12141a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
}

textarea { min-height: 90px; resize: vertical; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 10px; }

button.action {
  background: var(--accent);
  color: #14161a;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
}

button.danger {
  background: rgba(217, 96, 96, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-weight: 600;
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

button.danger:active { transform: scale(0.96); background: rgba(217, 96, 96, 0.22); }

button[disabled] { opacity: 0.5; cursor: default; }

.chips { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.chip.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.emoji-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

.emoji-chip {
  width: 44px;
  height: 44px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
}

.emoji-chip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.attach-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.attach-clip {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.attach-clip:hover { border-color: var(--accent); }

.attach-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 210px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12141a;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-link:hover { border-color: var(--accent); color: var(--accent); }

.attach-clear {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.attach-clear:hover { color: var(--danger); border-color: var(--danger); }

.candle-thumb {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.order-actions { margin-top: 12px; }

.chevron {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.15s ease;
}

.chevron.open {
  transform: rotate(180deg);
  border-color: var(--accent);
  color: var(--accent);
}

.receipt-thumb {
  display: inline-flex;
  padding: 0;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #12141a;
  cursor: zoom-in;
  overflow: hidden;
  line-height: 0;
}

.receipt-thumb img {
  display: block;
  height: 64px;
  width: auto;
}

.viewer-box {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  padding: 10px;
}

.viewer {
  position: relative;
}

.viewer img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 80vh;
  margin: 0 auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.sheet-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(20, 22, 26, 0.85);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 11, 14, 0.82);
  backdrop-filter: blur(3px);
  padding: 16px;
  overflow-y: auto;
}

.sheet-box {
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
}

.sheet-box h2 { margin: 0 0 10px; }

.editor-box { max-width: 540px; }

#editor-text {
  min-height: 40vh;
  font-size: 14px;
  line-height: 1.5;
}

.text-preview {
  max-height: 64px;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  margin-top: 6px;
}

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
}

.status.ok { color: var(--ok); border-color: var(--ok); }
.status.wait { color: var(--accent); border-color: var(--accent); }
.status.bad { color: var(--danger); border-color: var(--danger); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #232833;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 90%;
  z-index: 20;
}

.hidden { display: none; }
.error { color: var(--danger); font-size: 13px; }

.bar { height: 6px; background: #12141a; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }