:root {
  --bg: #f5f7f8; --panel: #ffffff; --ink: #14201f; --muted: #5f6f6d; --line: #e2e8e7;
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #e6f4f2;
  --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2; --ok: #15803d; --ok-soft: #dcfce7;
  --side: #0d1f1d; --side-ink: #c9d6d4; --side-active: #16332f;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1211; --panel: #121c1b; --ink: #e6eeed; --muted: #93a5a2; --line: #22312f;
    --brand: #2dd4bf; --brand-ink: #062a26; --brand-soft: #123a35;
    --warn: #fbbf24; --warn-soft: #3a2e0f; --bad: #f87171; --bad-soft: #3b1414; --ok: #4ade80; --ok-soft: #12321e;
    --side: #070d0c; --side-ink: #a9bbb8; --side-active: #13302c; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }

.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: #0f766e; display: grid; place-items: center; font-size: 12px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--side-ink); padding: 8px 10px; border-radius: 8px; }
.nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav a .lock { font-size: 10px; background: #334; color: #ccd; padding: 1px 6px; border-radius: 99px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.top .who { display: flex; align-items: center; gap: 10px; }
.btn.menu-btn { display: none; }
.content { padding: 24px; max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat .label { color: var(--muted); font-size: 12px; } .stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--bad); } .btn.sm { padding: 3px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: color-mix(in srgb, var(--brand-soft) 35%, transparent); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.table-wrap table { min-width: 640px; }
.card .table-wrap table { min-width: 0; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.grey { background: var(--line); color: var(--muted); }

form .row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.f.full { grid-column: 1 / -1; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
input[type=checkbox] { width: auto; }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--ink) !important; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 14px; }
legend { font-weight: 600; padding: 0 6px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-color: var(--brand); font-weight: 600; text-decoration: none; }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: min(760px, 100%); max-height: 92vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 20px; } .modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }

#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 420px; white-space: pre-line; }
.toast.bad { background: var(--bad); color: #fff; }

.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--warn-soft); color: var(--warn); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth { width: min(420px, 100%); }
.upsell { text-align: center; padding: 48px 24px; }
.upsell .icon { font-size: 36px; }
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.pkg { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--panel); }
.pkg.current { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.pkg .price { font-size: 24px; font-weight: 700; margin: 6px 0; }
.pkg ul { padding-left: 18px; margin: 10px 0 0; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--brand); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 12px; }

.slip { max-width: 760px; margin: 0 auto; }
.slip table td, .slip table th { padding: 6px 8px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; } .top { padding: 10px 16px; }
  .kv { grid-template-columns: 1fr; }
}
@media (max-width: 520px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* ---- Suite top bar: app mark on the left, company menu on the right (same as Sales CRM) ---- */
.app-mark { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-icon { width: 30px; height: 30px; flex: none; border-radius: 8px; background: var(--app, #7a5af5); color: #fff; display: grid; place-items: center; }
.app-icon svg { width: 18px; height: 18px; }
.app-word { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-mark { display: none; font-weight: 700; }
.page-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.top .who { min-width: 0; }
.user-name { white-space: nowrap; }
.icon-btn svg { width: 15px; height: 15px; flex: none; }

.org { position: relative; }
.org-btn { display: inline-flex; align-items: center; gap: 8px; max-width: 260px; height: 32px; padding: 0 10px 0 4px; border: 1px solid var(--line); border-radius: 99px; background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.org-btn:hover, .org-btn[aria-expanded="true"] { border-color: #7a5af5; }
.org-btn:focus-visible { outline: 2px solid #7a5af5; outline-offset: 2px; }
.org-logo { width: 24px; height: 24px; flex: none; border-radius: 50%; background: #7a5af5; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; overflow: hidden; }
.org-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.org-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-caret { font-size: 10px; color: var(--muted); }
.org-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 320px; max-width: calc(100vw - 24px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 14px; z-index: 50; }
.org-panel[hidden] { display: none; }
.org-head { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.org-head .org-logo { width: 36px; height: 36px; font-size: 15px; }
.org-title { font-weight: 700; }
.org-tick { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 10px; vertical-align: 1px; }
.org-plan { font-size: 12px; color: var(--muted); }
.org-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 8px; }
.org-apps { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.org-app { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; color: var(--ink); font-weight: 500; font-size: 13px; }
.org-app:hover { background: var(--bg); text-decoration: none; }
.org-app.current { background: color-mix(in srgb, #7a5af5 12%, transparent); }
.org-app .app-icon { width: 28px; height: 28px; }
.org-account { display: block; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 600; }

/* Narrower screens: the company button becomes a round initial, then words give way to icons. */
@media (max-width: 1700px) {
  .org-btn { width: 32px; padding: 0; justify-content: center; }
  .org-btn .org-name, .org-btn .org-caret { display: none; }
  .org-btn .org-logo { width: 30px; height: 30px; }
}
@media (max-width: 1100px) { .btn-word { display: none; } .icon-btn { padding: 5px 8px; } }
@media (max-width: 900px) {
  .top-mark { display: flex; }
  .page-name { font-weight: 500; color: var(--muted); }
  .org { position: static; }
  .org-panel { position: fixed; top: 58px; right: 12px; }
}
@media (max-width: 640px) {
  .top .user-name, .top .lic { display: none; }
  .top-mark .app-word { display: none; }
  .top { gap: 8px; }
}
@media (max-width: 400px) { .page-name { display: none; } .top-mark .app-word { display: inline; } }
@media print {
  .side, .top, .no-print { display: none !important; }
  .layout { display: block; } .content { padding: 0; } .card { box-shadow: none; border: 0; }
  body { background: #fff; color: #000; }
}

.client-brand { display: grid; place-items: center; height: 72px; margin-bottom: 8px; }
.client-brand img { max-width: 220px; max-height: 72px; object-fit: contain; }
/* demo install banner */
.demo-banner { background: #fff6dd; color: #6b4a00; border-bottom: 1px solid #f0d48a; padding: 8px 16px; font-size: 13px; text-align: center; }
.demo-banner a { color: inherit; font-weight: 600; text-decoration: underline; }
