:root {
  --bg: #f3f5f4;
  --bg2: #ffffff;
  --panel: #ffffff;
  --line: #e3e9e5;
  --text: #17231e;
  --muted: #5f6f66;
  --accent: #1f9d63;
  --accent2: #178a54;
  --accent-soft: #e8f7ef;
  --warn: #b07a1a;
  --warn-soft: #fff6e5;
  --danger: #c44545;
  --danger-soft: #f8e8e8;
  --ok: #1f9d63;
  --violet: #5b6cff;
  --violet-soft: #eef0ff;
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.03), 0 8px 24px rgba(16, 24, 20, 0.05);
  --side: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent2); }

.layout { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  background: #fff; border-right: 1px solid var(--line);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow: auto;
}
.side .brand { padding: 4px 10px 18px; }
.side .brand strong { display: block; font-size: 1.15rem; letter-spacing: -0.02em; }
.side .brand span { color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  text-align: left; border: 0; background: transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 500;
}
.nav button:hover { background: #f4f7f5; color: var(--text); }
.nav button.on { background: var(--accent-soft); color: var(--accent2); font-weight: 700; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.main { padding: 22px 24px 64px; max-width: 1180px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.topbar .sub { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.hrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.hrow h2 { margin: 0; font-size: 1.05rem; }
.muted { color: var(--muted); }
.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600;
}
.btn:hover { filter: brightness(1.05); }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: 0.85rem; color: var(--muted); }
.field input:not([type="checkbox"]):not([type="radio"]),
.field textarea,
.field select {
  width: 100%; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none;
}
.field input:not([type="checkbox"]):not([type="radio"]):focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,157,99,.15);
}
.field textarea { min-height: 140px; resize: vertical; line-height: 1.4; }
.field input[type="checkbox"],
.field input[type="radio"] {
  width: auto; min-width: 16px; height: 16px; margin: 0; flex: 0 0 auto;
  accent-color: var(--accent);
}

.card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px;
}
.card .title { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.card .title b { font-size: 1rem; }

.check-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 180px; overflow: auto; padding: 8px;
  background: #f7faf8; border: 1px solid var(--line); border-radius: 10px;
}
.check-list label {
  display: flex; align-items: center; gap: 10px;
  margin: 0; padding: 8px 10px; border-radius: 8px;
  font-size: 0.92rem; color: var(--text); cursor: pointer;
}
.check-list label:hover { background: #fff; }
.check-list input[type="checkbox"] {
  width: 16px; height: 16px; margin: 0; flex: 0 0 auto; accent-color: var(--accent);
}
.check-inline {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 12px; color: var(--text); cursor: pointer; font-size: 0.92rem;
}
.check-inline input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

.g-toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 12px;
}
.g-toolbar input[type="search"] {
  flex: 1; min-width: 160px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px;
}
.g-list { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow: auto; }
.g-item {
  display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.g-item .g-name { font-weight: 700; font-size: 0.98rem; word-break: break-word; }
.g-item .g-meta { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.g-item .g-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.g-item .g-actions .btn { padding: 7px 10px; font-size: 0.82rem; }
.g-side { position: sticky; top: 12px; align-self: start; }
@media (max-width: 900px) {
  .g-item { grid-template-columns: 1fr; }
  .g-item .g-actions { justify-content: flex-start; }
  .g-side { position: static; }
}
.metric {
  border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  background: linear-gradient(180deg, #fff, #fafcfb);
}
.metric .val { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.03em; margin: 4px 0; }
.metric .lbl { color: var(--muted); font-size: 0.85rem; }
.metric.green { background: linear-gradient(180deg, #f3fbf6, #fff); border-color: #d7efe2; }
.metric.violet { background: linear-gradient(180deg, #f5f6ff, #fff); border-color: #dde1ff; }
.metric.warm { background: linear-gradient(180deg, #fff8ee, #fff); border-color: #f0e0c4; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
}
.pill.open, .pill.done, .pill.replied { background: #e7f6ee; color: var(--ok); }
.pill.qr, .pill.connecting, .pill.paused, .pill.scheduled { background: #fff6e5; color: var(--warn); }
.pill.running { background: var(--violet-soft); color: var(--violet); }
.pill.failed, .pill.canceled, .pill.closed, .pill.logged_out { background: var(--danger-soft); color: var(--danger); }

.bar {
  height: 8px; background: #eef2f0; border-radius: 999px; overflow: hidden; margin-top: 8px;
}
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.qrbox {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 16px; background: #f7faf8; border-radius: 12px; border: 1px dashed var(--line);
}
.qrbox img { width: 220px; height: 220px; background: #fff; border-radius: 8px; }
.paircode {
  font-family: var(--mono); font-size: 2rem; letter-spacing: 0.28em;
  padding: 14px 18px; background: #f7faf8; border-radius: 12px;
  border: 1px solid var(--accent); color: var(--accent2); text-align: center;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.stat { font-size: 0.82rem; color: var(--muted); }
.stat b { color: var(--text); font-weight: 600; }
.hint {
  font-size: 0.82rem; color: var(--muted); background: #f7faf8;
  border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0 14px;
}
.eta {
  background: var(--accent-soft); color: var(--accent2); border-radius: 10px;
  padding: 10px 12px; font-weight: 600; margin-top: 8px;
}

.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #fff;
}
.login .box { width: min(400px, 100%); }
.login h1 { margin: 0 0 6px; font-size: 1.6rem; letter-spacing: -0.03em; }
.err { color: var(--danger); font-size: 0.9rem; margin-top: 8px; }
.okmsg { color: var(--ok); font-size: 0.9rem; margin-top: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.ai-preview, .preview-box {
  white-space: pre-wrap; background: #f7faf8; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; min-height: 80px; line-height: 1.45;
}
.ask-card { border-left: 3px solid var(--accent); }
.ask-card p { line-height: 1.4; }
.mono { font-family: var(--mono); font-size: 0.85em; }
.cl-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cl-board.cl-pipe {
  grid-template-columns: repeat(7, minmax(160px, 1fr));
  overflow-x: auto; padding-bottom: 6px;
}
@media (max-width: 900px) { .cl-board { grid-template-columns: 1fr; } }
.cl-col { background: #f7faf8; border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 180px; }
.cl-colhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding: 0 4px; }
.cl-colbody { display: grid; gap: 8px; }
.cl-card { cursor: grab; }
.cl-quickst {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; font-size: 0.8rem; max-width: 120px;
}
.cl-filters { flex-wrap: wrap; margin: 0 0 14px; gap: 8px; }
.cl-filters select, .cl-filters input {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; min-width: 140px;
}
.cl-filters input { flex: 1; min-width: 160px; }
.sep-dot { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.cl-week {
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px;
}
@media (max-width: 900px) { .cl-week { grid-template-columns: repeat(4, 1fr); } }
.cl-day {
  background: #f7faf8; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; min-height: 78px; display: grid; gap: 4px; align-content: start;
}
.cl-day.today { border-color: var(--accent); background: var(--accent-soft); }
.cl-day.has-over { border-color: #e8a0a0; }
.cl-dn { font-size: 0.75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.cl-pill {
  border: 0; background: #fff; border-radius: 6px; padding: 3px 6px;
  font-size: 0.72rem; text-align: left; cursor: pointer; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--line);
}
.cl-pill:hover { border-color: var(--accent); }
.cl-touch { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 4px; }
.cl-logline { margin-bottom: 4px; }
.stbadge {
  display: inline-block; color: #fff; font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
}
.due-badge {
  display: inline-block; margin-top: 8px; font-size: 0.8rem; font-weight: 600;
  background: var(--warn-soft); color: var(--warn); padding: 3px 8px; border-radius: 8px;
}
.due-badge.over { background: var(--danger-soft); color: var(--danger); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent2); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: #f4f7f5; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px; font-size: 0.78rem; color: var(--muted); cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent2); }
