:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #17221f;
  --ink-2: #3c4a46;
  --muted: #6b7874;
  --line: #e3e8e6;
  --field: #d5ddda;
  --field-bg: #fbfcfc;
  --brand: #2a7a68;
  --brand-dark: #1d5c4e;
  --brand-ink: #ffffff;
  --brand-soft: #e2f1ec;
  --brand-ring: rgba(42, 122, 104, 0.18);
  --warn: #a8670f;
  --warn-soft: #fcf1de;
  --danger: #b23b33;
  --danger-soft: #fbe8e6;
  --info: #31679f;
  --info-soft: #e6eef8;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 34, 30, 0.04), 0 4px 16px rgba(16, 34, 30, 0.05);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14.5px; line-height: 1.45; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
[hidden] { display: none !important; }

/* ---------- layout and menu ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: #15302a; color: #c9dbd5; padding: 18px 14px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; font-size: 16px; padding: 4px 8px 20px; }
.sidebar .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #3fa58c, #2a7a68); display: grid; place-items: center; font-size: 13px; letter-spacing: .02em; }
.nav-group { display: grid; gap: 2px; margin-bottom: 14px; }
.nav-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #7fa39a; padding: 6px 10px 4px; }
.sidebar a { color: inherit; text-decoration: none; padding: 9px 10px; border-radius: 10px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.sidebar a span:not(.badge-count) { flex: 1; }
.sidebar a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar a.active { background: rgba(255,255,255,0.12); color: #fff; }
.sidebar a.active .ic { color: #7fd7bf; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar .spacer { flex: 1; }
.sidebar .meta { font-size: 12px; color: #86a59d; padding: 10px; }
.sidebar .meta .bold { color: #d6e7e1; }
.sidebar .meta a.meta-link { display: inline; padding: 0; color: #a9d8c9; text-decoration: underline; font-weight: 400; }
.badge-count { background: #e0912b; color: #fff; border-radius: 999px; font-size: 11px; font-weight: 600; padding: 1px 7px; }
main { padding: 28px 32px 40px; min-width: 0; max-width: 1280px; width: 100%; }
.content { display: flex; flex-direction: column; min-width: 0; }
.content main { flex: 1; }
.sidebar .logo-img { border-radius: 10px; flex: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }

.banner { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; background: var(--warn-soft); color: #7a5214; border: 1px solid #f0dcb4; }

/* ---------- cards and panels ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.card .foot { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 10px; flex-wrap: wrap; }
.panel-body { padding: 20px; }

/* ---------- buttons and fields ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border: 1px solid var(--field); background: var(--panel); padding: 8px 16px; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; font-weight: 500; text-decoration: none; color: var(--ink); transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { border-color: #b9c5c1; background: #f8faf9; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--brand-ring); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { border: 1.5px solid var(--field); border-radius: var(--radius-sm); padding: 10px 14px; background: var(--field-bg); min-height: 44px; font-size: 15px; transition: border-color .12s, box-shadow .12s, background .12s; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--brand); }
input[type=search] { min-width: 240px; }
input::placeholder, textarea::placeholder { color: #9aa7a3; }
input:hover, select:hover, textarea:hover { border-color: #b9c5c1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px var(--brand-ring); }
input[readonly] { background: #f1f4f3; color: var(--ink-2); }
input:disabled, select:disabled, textarea:disabled { background: #f1f4f3; color: var(--ink-2); cursor: not-allowed; }
textarea { width: 100%; min-height: 84px; resize: vertical; line-height: 1.5; }
select { appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7874' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }

.form { display: grid; gap: 16px; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); align-content: start; }
.form label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 14.5px; font-weight: 500; cursor: pointer; }
.form input:not([type=checkbox]), .form select { width: 100%; }
.hint, .form label .hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.form .row.item-row, .form .row.hint { grid-template-columns: 2fr 1fr 1fr auto; align-items: center; }
.form .row.item-row.item5 { grid-template-columns: 2fr 1fr 1fr 1.5fr auto; }
.form .row.plan-row { grid-template-columns: 1fr 1fr auto; align-items: center; }
.form .row.hint span { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.form h3 { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }

/* Registration: numbered sections */
.form-section .panel-head h2 { display: flex; align-items: center; gap: 12px; }
.form-section .step { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.sticky-foot { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 18px 0 12px; z-index: 2; }
.sticky-foot .btn.primary { min-height: 48px; padding: 10px 28px; font-size: 15.5px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #f8faf9; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f5f9f8; }
tr.group td { background: #f1f5f4; font-weight: 600; font-size: 13px; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.bold { font-weight: 600; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status.pending { background: var(--warn-soft); color: var(--warn); }
.status.confirmed { background: var(--brand-soft); color: var(--brand); }
.status.completed { background: var(--info-soft); color: var(--info); }
.status.cancelled, .status.no_show { background: var(--danger-soft); color: var(--danger); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; background: #edf1ef; color: var(--muted); }
code { background: #edf1ef; padding: 1px 6px; border-radius: 5px; }
.danger-text { color: var(--danger); }

/* ---------- modal, toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(14, 28, 25, .45); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 20; }
.modal { background: var(--panel); border-radius: 18px; width: 100%; max-width: 640px; box-shadow: 0 24px 60px rgba(0,0,0,.22); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; background: #fafbfb; border-radius: 0 0 18px 18px; }
.x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); width: 36px; height: 36px; border-radius: 8px; }
.x:hover { background: #f1f4f3; }
.error { color: var(--danger); font-size: 13.5px; font-weight: 500; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #15302a; color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 30; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
dl.details { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; margin: 0 0 16px; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; }

/* ---------- dashboard ---------- */
.stat { display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: inherit; }
a.stat:hover { border-color: #c4d3ce; }
.stat .stat-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); }
.stat .stat-ic .ic { width: 20px; height: 20px; }
.stat.warn .stat-ic { background: var(--warn-soft); color: var(--warn); }
.stat.danger .stat-ic { background: var(--danger-soft); color: var(--danger); }
.stat.info .stat-ic { background: var(--info-soft); color: var(--info); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; margin-bottom: 20px; }
.dash-grid .panel { margin-bottom: 0; }
.chart { padding: 18px 20px 14px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { fill: var(--brand); }
.chart .bar.today { fill: #1d5c4e; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar:hover { fill: #3fa58c; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 13px; font-family: inherit; }
.chart text.val { fill: var(--ink-2); font-weight: 600; }
.chart-tip { position: fixed; pointer-events: none; background: #15302a; color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12.5px; z-index: 40; white-space: nowrap; }
.hbars { display: grid; gap: 12px; padding: 18px 20px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 170px) 1fr 36px; gap: 12px; align-items: center; font-size: 13.5px; }
.hbar .track { background: #eef3f1; border-radius: 6px; height: 10px; overflow: hidden; }
.hbar .fill { background: var(--brand); height: 100%; border-radius: 6px; }
.hbar .n { text-align: right; font-weight: 600; color: var(--ink-2); }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: none; }
a.list-row { color: inherit; text-decoration: none; }
a.list-row:hover { background: #f5f9f8; }
.time-chip { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 72px; }

/* Simulator */
.sim { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 20px; align-items: start; }
.phone { background: #e9e4dc; border-radius: 22px; border: 8px solid #1d2524; height: 680px; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.phone-head { background: #075e54; color: #fff; padding: 12px 14px; font-weight: 600; }
.phone-head .small { font-weight: 400; opacity: .8; }
.chat { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 85%; padding: 7px 10px; border-radius: 8px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.08); line-height: 1.35; }
.bubble.in { align-self: flex-end; background: #d9fdd3; }
.bubble.out { align-self: flex-start; background: #fff; }
.bubble .head { font-weight: 600; margin-bottom: 4px; }
.bubble .foot { color: var(--muted); font-size: 12px; margin-top: 4px; }
.bubble .actions { display: grid; gap: 1px; margin: 8px -10px -7px; border-top: 1px solid #eee; }
.bubble .actions button { background: #fff; border: none; padding: 8px; color: #027eb5; cursor: pointer; border-top: 1px solid #f0f0f0; }
.bubble .actions button:hover { background: #f6f6f6; }
.bubble.used .actions button { color: #9ab; cursor: default; }
.composer { display: flex; gap: 6px; padding: 8px; background: #f0f0f0; }
.composer input { flex: 1; border-radius: 20px; }
.sheet { position: absolute; inset: auto 0 0 0; background: #fff; border-radius: 14px 14px 0 0; max-height: 75%; overflow-y: auto; box-shadow: 0 -8px 30px rgba(0,0,0,.2); }
.sheet h3 { padding: 14px 16px 6px; font-size: 15px; }
.sheet .section { padding: 8px 16px 2px; color: #128c7e; font-size: 12px; font-weight: 600; }
.sheet button.row { display: block; width: 100%; text-align: left; border: none; background: none; padding: 10px 16px; border-bottom: 1px solid #f1f1f1; cursor: pointer; }
.sheet button.row:hover { background: #f7f7f7; }
.sheet .row .desc { color: var(--muted); font-size: 12px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; padding: 8px; gap: 2px; position: sticky; top: 0; z-index: 10; height: auto; }
  .sidebar .brand, .sidebar .spacer, .sidebar .meta, .nav-title { display: none; }
  .nav-group { display: flex; margin: 0; }
  .sidebar a { white-space: nowrap; }
  main { padding: 18px 16px 30px; }
      .sim { grid-template-columns: 1fr; }
  .phone { height: 600px; }
  .dash-grid { grid-template-columns: 1fr; }
  input[type=search] { min-width: 0; width: 100%; }
  .form .row.item-row, .form .row.item-row.item5 { grid-template-columns: 1fr 1fr; }
  .form .row.hint { display: none; }
}
@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .stat .stat-ic { display: none; }
  .card .value { font-size: 20px; }
  h1 { font-size: 21px; }
}
ul.plain-list { margin: 0; padding-left: 20px; color: var(--ink-2); }
ul.plain-list li { margin: 4px 0; }
.role-table td { vertical-align: top; }
.role-table td:first-child { white-space: nowrap; width: 1%; }
.wa-checks { list-style: none; margin: 0; padding: 0; }
.wa-checks li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.wa-checks li:last-child { border-bottom: none; }
.wa-detail { overflow-wrap: anywhere; }
.wa-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; }
.wa-mark.ok { background: #2f9e6e; }
.wa-mark.bad { background: #c8473d; }
.wa-mark.info { background: #9aa9a4; font-style: italic; }
