:root {
  --navy: #102c3a;
  --navy-2: #173e4d;
  --ink: #17262f;
  --muted: #667985;
  --line: #dfe8eb;
  --surface: #ffffff;
  --canvas: #f3f7f8;
  --teal: #00a98f;
  --teal-dark: #008b77;
  --teal-soft: #e4f7f3;
  --orange: #ed8a2c;
  --red: #d84b51;
  --green: #179b68;
  --shadow: 0 12px 35px rgba(29, 58, 70, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }

.app-shell { display: grid; grid-template-columns: 256px 1fr; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 256px; padding: 26px 18px; color: #eaf5f5; background: linear-gradient(180deg, #102f3d 0%, #0b2430 100%); display: flex; flex-direction: column; overflow-y: auto; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; line-height: 1.25; }
.brand small { margin-top: 3px; color: #8db0b9; font-size: 11px; letter-spacing: .03em; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: white; background: var(--teal); font-weight: 900; font-size: 22px; box-shadow: 0 8px 22px rgba(0, 169, 143, .28); }
.brand-dark { color: var(--ink); margin-bottom: 32px; }
.brand-dark small { color: var(--muted); }
.sidebar nav { margin-top: 36px; display: grid; gap: 6px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 11px 12px; color: #b9cdd2; text-decoration: none; border-radius: 10px; font-size: 14px; transition: .15s ease; }
.nav-link:hover, .nav-link.active { color: white; background: rgba(255,255,255,.08); }
.nav-link.active { font-weight: 700; }
.nav-dot { width: 8px; height: 8px; border: 2px solid currentColor; border-radius: 50%; }
.nav-link.active .nav-dot { border-color: var(--teal); background: var(--teal); box-shadow: 0 0 0 4px rgba(0,169,143,.15); }
.local-chip { margin-top: auto; padding: 10px; border: 1px solid rgba(255,255,255,.09); border-radius: 10px; color: #9fbbc2; font-size: 11px; }
.local-chip span { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--green); }
.sidebar-user { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sidebar-user small, .sidebar-user strong { display: block; }
.sidebar-user small { color: #7799a2; font-size: 10px; text-transform: uppercase; }
.sidebar-user strong { margin-top: 2px; font-size: 13px; }
.link-button { padding: 0; border: 0; color: #9fbbc2; background: none; cursor: pointer; font-size: 12px; }

.main-content { grid-column: 2; min-width: 0; padding: 42px clamp(24px, 4vw, 64px) 64px; }
.menu-button { display: none; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.page-header h1 { margin: 5px 0 4px; font-size: clamp(28px, 3vw, 39px); line-height: 1.05; letter-spacing: -.035em; }
.page-header p { max-width: 720px; margin: 0; color: var(--muted); font-size: 14px; }
.eyebrow { color: var(--teal-dark); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

.button { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; background: white; color: var(--ink); font-weight: 750; font-size: 13px; cursor: pointer; transition: .15s ease; }
.button:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(26,60,72,.1); }
.button.primary { color: white; background: var(--teal); border-color: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { background: #f8fbfb; }
.button.small { min-height: 34px; padding: 7px 12px; }
.full-width { width: 100%; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card, .panel, .plan-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stat-card { position: relative; overflow: hidden; padding: 22px; }
.stat-card::after { content: ""; position: absolute; width: 56px; height: 56px; right: -18px; top: -18px; border-radius: 50%; background: var(--teal-soft); }
.stat-card span, .stat-card small, .stat-card strong { display: block; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { margin: 9px 0 4px; font-size: 27px; letter-spacing: -.03em; }
.stat-card small { color: #8b9aa2; font-size: 11px; }
.panel { padding: 22px; margin-bottom: 18px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.panel-heading h2, .section-title h2 { margin: 4px 0 0; font-size: 18px; }
.section-title p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.split-grid { display: grid; grid-template-columns: minmax(280px, .7fr) minmax(520px, 1.3fr); gap: 18px; }
.router-summary { color: #eaf5f5; background: linear-gradient(135deg, var(--navy), var(--navy-2)); border: 0; }
.router-summary .eyebrow { color: #60dac7; }
.router-summary h2 { margin: 4px 0; }
.router-message { min-height: 38px; color: #a8c2c8; font-size: 13px; }
.router-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.router-facts div { padding: 12px; border-radius: 10px; background: rgba(255,255,255,.07); }
.router-facts span, .router-facts strong { display: block; }
.router-facts span { color: #88aab2; font-size: 10px; text-transform: uppercase; }
.router-facts strong { margin-top: 3px; font-size: 13px; }

.connection-dot { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; background: #93a4ab; box-shadow: 0 0 0 5px rgba(147,164,171,.14); }
.connection-dot.online { background: #34ce8d; box-shadow: 0 0 0 5px rgba(52,206,141,.15); }
.connection-dot.offline { background: #ee6a70; box-shadow: 0 0 0 5px rgba(238,106,112,.14); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; color: #7a8d96; text-align: left; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
td { padding: 13px 12px; border-bottom: 1px solid #edf2f3; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: #8a9aa2; font-size: 10px; }
code { padding: 2px 5px; border-radius: 5px; background: #f1f5f6; color: #31515e; font-size: 11px; }
.money { white-space: nowrap; font-weight: 750; }
.money.negative, .negative { color: var(--red); }
.empty-cell, .empty-state { padding: 30px; color: #8a9aa2; text-align: center; }
.actions { display: flex; gap: 9px; align-items: center; white-space: nowrap; }
.actions form { margin: 0; }
.icon-link, .text-link { padding: 0; border: 0; color: var(--teal-dark); background: none; text-decoration: none; font-size: 11px; font-weight: 750; cursor: pointer; }
.danger-text { color: var(--red); }
.success-text { color: var(--green); }
.text-link { font-size: 12px; }

.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; background: #edf2f3; color: #53666f; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge-active, .badge-assigned, .badge-payment, .badge-bypassed { color: #087b54; background: #e5f7ef; }
.badge-suspended, .badge-retired { color: #aa363c; background: #fdecee; }
.badge-charge, .badge-repair { color: #a55d16; background: #fff1df; }
.badge-in_stock { color: #236d91; background: #e7f4fa; }
.badge-assigned { color: #236d91; background: #e7f4fa; }
.badge-in_progress { color: #a55d16; background: #fff1df; }
.badge-completed { color: #087b54; background: #e5f7ef; }
.badge-reported, .badge-cancelled { color: #aa363c; background: #fdecee; }
.badge-pending, .badge-open { color: #a55d16; background: #fff1df; }
.badge-approved, .badge-answered, .badge-closed { color: #087b54; background: #e5f7ef; }
.badge-rejected, .badge-duplicate { color: #aa363c; background: #fdecee; }

.toolbar { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 18px; }
.search { width: min(360px, 100%); }
.search span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.muted { color: var(--muted); font-size: 11px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-stack { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field span { color: #52666f; font-size: 11px; font-weight: 700; }
.field input, .field select, .field textarea, .search input { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid #cad8dc; border-radius: 9px; outline: 0; color: var(--ink); background: white; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,169,143,.1); }
.full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 7px; }
.section-title { padding-bottom: 3px; }
.section-title:not(:first-child) { margin-top: 7px; padding-top: 20px; border-top: 1px solid var(--line); }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; color: #52666f; font-size: 12px; }
.check-row input { accent-color: var(--teal); }
.check-row.critical { padding: 12px; border-radius: 10px; background: var(--teal-soft); color: #1a6257; }
.two-column { display: grid; grid-template-columns: minmax(280px, .65fr) minmax(0, 1.35fr); gap: 18px; align-items: start; }
.two-column.wide-right { grid-template-columns: minmax(300px, .55fr) minmax(0, 1.45fr); }
.sticky-panel { position: sticky; top: 22px; }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.plan-card { padding: 22px; }
.plan-card h2 { margin: 5px 0 20px; font-size: 17px; }
.plan-speed { display: block; font-size: 32px; }
.plan-speed small { font-size: 12px; color: var(--muted); }
.plan-card p { color: var(--muted); font-size: 12px; }
.plan-price { margin: 18px 0 10px; color: var(--teal-dark); font-size: 20px; font-weight: 850; }
.plan-price small { color: var(--muted); font-size: 10px; }
.card-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.safety-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; margin-bottom: 18px; border-radius: 13px; }
.safety-banner.safe { color: #166453; background: #dff5ef; border: 1px solid #bde8dc; }
.safety-banner.live { color: #8b4414; background: #fff0df; border: 1px solid #f4cfaa; }
.safety-banner p { margin: 3px 0 0; font-size: 12px; }
.safety-banner > span { font-size: 11px; font-weight: 900; letter-spacing: .1em; }
.connection-card { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.connection-card strong, .connection-card p { display: block; margin: 0; }
.connection-card p { margin-top: 3px; color: var(--muted); font-size: 11px; }
.warning-box { padding: 14px; border-left: 3px solid var(--orange); background: #fff8ef; border-radius: 7px; }
.warning-box strong { font-size: 12px; }
.warning-box p { margin: 4px 0 0; color: #855e3b; font-size: 11px; }

.notices { display: grid; gap: 8px; margin-bottom: 12px; }
.notice { padding: 12px 15px; border-radius: 10px; font-size: 12px; }
.notice-success { color: #126249; background: #e4f7ef; border: 1px solid #bce8d9; }
.notice-error { color: #98363b; background: #fdebed; border: 1px solid #f4c5c8; }
.notice-info { color: #27677d; background: #e8f4f8; border: 1px solid #c9e3ec; }

.auth-shell { display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 20% 20%, #d9f2ef 0, transparent 35%), linear-gradient(135deg, #eef6f6, #f8fafb); }
.auth-content { width: min(520px, 100%); }
.auth-card { padding: clamp(26px, 5vw, 42px); border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: 0 25px 70px rgba(24,61,74,.13); }
.setup-card { width: min(720px, 100%); margin-left: auto; margin-right: auto; }
.auth-content:has(.setup-card) { width: min(720px, 100%); }
.auth-heading { margin-bottom: 24px; }
.auth-heading h1 { margin: 7px 0; font-size: 30px; letter-spacing: -.03em; }
.auth-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.security-note { margin: 20px 0 0; color: #7d8d95; text-align: center; font-size: 10px; }
.small-value { font-size: 16px !important; overflow-wrap: anywhere; }
.admin-evidence-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.admin-evidence { margin: 0; }
.admin-evidence img { width: 100%; height: 180px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.admin-evidence figcaption { margin-top: 4px; color: var(--muted); font-size: 10px; }
.signature-image { max-width: 100%; max-height: 210px; object-fit: contain; border: 1px dashed var(--line); border-radius: 10px; background: white; }
.roles-grid { display: grid; grid-template-columns: minmax(240px,.4fr) minmax(0,1.6fr); gap: 18px; align-items: start; }
.role-list { display: grid; gap: 8px; }
.role-link { display: block; padding: 11px; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; }
.role-link strong,.role-link small { display: block; }
.role-link small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.permissions-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.permission-check { display: flex; gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.permission-check input { accent-color: var(--teal); }
.permission-check strong,.permission-check small { display: block; }
.permission-check strong { font-size: 11px; }
.permission-check small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.inline-response { display: grid; grid-template-columns: minmax(160px,1fr) auto auto; gap: 6px; }
.inline-response input,.inline-response select { min-height: 34px; padding: 6px; border: 1px solid var(--line); border-radius: 7px; }
.receipt-sheet { width: min(760px,100%); margin: 0 auto; padding: 34px; border: 1px solid var(--line); border-top: 7px solid var(--receipt-color); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.receipt-top,.receipt-meta,.receipt-totals p,.receipt-payment { display: flex; justify-content: space-between; gap: 20px; }
.receipt-top span,.receipt-meta small { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.receipt-top h1 { margin: 4px 0 0; font-size: 27px; }
.receipt-top>strong { color: var(--receipt-color); font-size: 18px; }
.receipt-meta { margin: 24px 0; padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.receipt-meta div,.receipt-meta b,.receipt-meta span { display: block; }
.receipt-meta div:last-child { text-align: right; }
.receipt-meta span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.receipt-items { margin-bottom: 20px; }
.receipt-totals { width: min(360px,100%); margin-left: auto; }
.receipt-totals p { margin: 0; padding: 7px; border-bottom: 1px solid #edf2f3; }
.receipt-totals .grand { color: var(--receipt-color); font-size: 18px; }
.receipt-payment { margin-top: 22px; padding: 13px; border-radius: 9px; background: #f2f7f7; }
.receipt-sheet footer { margin-top: 24px; color: var(--muted); text-align: center; font-size: 11px; }
.receipt-actions { display: flex; justify-content: center; margin-top: 20px; }

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid, .two-column, .two-column.wide-right, .roles-grid { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; box-shadow: 15px 0 45px rgba(11,36,48,.22); }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 24px 16px 50px; }
  .menu-button { display: inline-flex; margin-bottom: 18px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: white; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .stat-grid, .plan-grid, .form-grid, .permissions-grid { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .actions { min-width: 230px; }
  .auth-shell { padding: 14px; }
  .admin-evidence-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
  .sidebar, .menu-button, .button, .actions { display: none !important; }
  .app-shell { display: block; }
  .main-content { padding: 0; }
  .panel, .stat-card { box-shadow: none; }
  .receipt-sheet { border: 0; box-shadow: none; }
}

.connection-strip { margin: 0 0 14px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f3faf8; font-size: 12px; }
.inbox-grid { display: grid; grid-template-columns: minmax(240px,.38fr) minmax(0,1fr); gap: 16px; min-height: 580px; }
.conversation-list { padding: 8px; max-height: 680px; overflow-y: auto; }
.conversation-row { display: grid; gap: 3px; padding: 13px; border-radius: 9px; color: inherit; text-decoration: none; }
.conversation-row:hover,.conversation-row.selected { background: var(--teal-soft); }
.conversation-row span,.conversation-row small,.conversation-head p { color: var(--muted); font-size: 10px; }
.conversation-panel { display: flex; flex-direction: column; padding: 18px; }
.conversation-head { display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.conversation-head h2,.conversation-head p { margin: 0; }
.message-list { display: flex; flex: 1; flex-direction: column; gap: 9px; min-height: 280px; max-height: 460px; padding: 18px 4px; overflow-y: auto; }
.message { max-width: 76%; padding: 10px 13px; border-radius: 12px; background: #eef3f4; }
.message-client { align-self: flex-start; }
.message-agent,.message-ai { align-self: flex-end; background: #dff5ef; }
.message-system { align-self: center; background: #fff5e6; }
.message small { color: var(--muted); font-size: 9px; }
.message p { margin: 4px 0 0; white-space: pre-wrap; font-size: 12px; }
.reply-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.reply-box textarea,.reply-box select { padding: 9px; border: 1px solid var(--line); border-radius: 8px; }
.reply-box textarea,.reply-box .check-row { grid-column: 1 / -1; }
.simulator { margin-top: 16px; }
.simulator summary { cursor: pointer; font-weight: 800; }
.simulator form { margin-top: 16px; }
.config-checklist { display: grid; gap: 10px; padding: 0; list-style: none; }
.config-checklist li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line); font-size: 12px; }
@media (max-width: 900px) { .inbox-grid { grid-template-columns: 1fr; } .conversation-head { flex-direction: column; } }
