/* Atlas styles. Colours are set once here as variables. */
:root {
  --bg: #F3F5F7;
  --panel: #FFFFFF;
  --panel-2: #F8FAFB;
  --line: #E3E8EC;
  --line-2: #CBD3D9;
  --text: #14181F;
  --text-2: #3A444C;
  --muted: #5B6770;
  --nav: #10181D;
  --nav-active: #1E2C34;
  --nav-text: #B5C2C9;
  --nav-muted: #8A9AA3;
  --accent: #0F766E;
  --accent-dark: #0B5A54;
  --accent-soft: #E6F2F1;
  --accent-bright: #14B8A6;
  --ok-bg: #E3F4E8; --ok: #146C3B;
  --warn-bg: #FEF3C7; --warn: #8A4B08; --warn-line: #F1D48A; --warn-panel: #FFF8E6; --warn-text: #4A2A06;
  --bad-bg: #FDECEC; --bad: #9B1C1C;
  --chip: #EBEEF1;
  --code-bg: #10181D; --code-text: #D9E4E8;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.mono, code, pre, kbd { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ico { flex: 0 0 auto; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { flex: 0 0 232px; background: var(--nav); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; font-size: 17px; font-weight: 600; }
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-bright); color: #06201E; font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 8px; font-weight: 500; color: var(--nav-text); }
.nav-link:hover { background: var(--nav-active); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--nav-active); color: #fff; }
.nav-link .count { margin-left: auto; font-size: 12px; color: var(--nav-muted); }
.nav-section { margin: 14px 10px 4px; font-size: 11.5px; font-weight: 600; color: var(--nav-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.nav-spacer { flex: 1; min-height: 24px; }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 10px 4px; border-top: 1px solid #22313A; color: #fff; }
.me .avatar { background: #2B3E48; color: #fff; }
.me-name { font-size: 13px; font-weight: 500; }
.me-role { font-size: 12px; color: var(--nav-muted); }
.me a { color: var(--nav-text); }
.me form { margin-left: auto; }
.icon-btn { background: transparent; border: 0; color: var(--nav-text); width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { background: var(--nav-active); color: #fff; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 32px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.searchbox { flex: 1 1 320px; max-width: 560px; display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 42px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.searchbox:focus-within { border-color: var(--accent); background: #fff; }
.searchbox input[type=search] { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; color: var(--text); padding: 0; min-height: 0; }
.nowrap { white-space: nowrap; }
.searchbox kbd { font-size: 12px; border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; }
.topbar .grow { flex: 1; }
.new-menu { position: relative; }
.new-menu > summary { list-style: none; }
.new-menu > summary::-webkit-details-marker { display: none; }
.new-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(16, 24, 29, 0.14); padding: 6px; display: flex; flex-direction: column; }
.new-menu .menu a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); font-weight: 500; min-height: 40px; }
.new-menu .menu a:hover, .new-menu .menu a:focus-visible { background: var(--panel-2); text-decoration: none; color: var(--text); outline: none; }
.new-menu .menu .ico { color: var(--muted); }
.menu-label { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.session-left { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.content { padding: 24px 32px 48px; width: 100%; max-width: 1280px; display: flex; flex-direction: column; gap: 20px; }

.bottom-nav { display: none; }

/* ---------------------------------------------------------------- buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-danger { color: var(--bad); border-color: #E8B4B4; }
.btn-danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-link { background: none; border: 0; padding: 0; height: auto; color: var(--accent); font-weight: 500; cursor: pointer; font: inherit; }
.btn-link.danger { color: var(--bad); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline { display: inline; margin: 0; }

.form { display: flex; flex-direction: column; gap: 16px; max-width: 760px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
label.field, .field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13.5px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=date], input[type=number], input[type=search], input[type=tel], select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: #fff; border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 12px; min-height: 40px; width: 100%;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
textarea.code-area { font-family: var(--mono); font-size: 13px; min-height: 420px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; }
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); }
.check .hint { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }

/* ---------------------------------------------------------------- panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; }
.card-head h2 { flex: 1; }
.card-head a, .card-head .muted { font-size: 13px; font-weight: 500; }
.card-body { padding: 0 20px 18px; }
.card-pad { padding: 18px 20px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); color: var(--text); }
a.row:hover { background: var(--panel-2); text-decoration: none; color: var(--text); }
.row .grow { flex: 1; min-width: 0; }
.row-title { font-weight: 500; }
.row-sub { font-size: 12.5px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.empty { padding: 22px 20px; border-top: 1px solid var(--line); color: var(--muted); }
.empty-big { padding: 40px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }

.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.col-main { flex: 2 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.col-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.stats { display: flex; flex-wrap: wrap; gap: 16px; }
.stat { flex: 1 1 200px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; color: var(--text); }
a.stat:hover { text-decoration: none; border-color: var(--line-2); color: var(--text); }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 32px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.stat-note { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.stat-note.good { color: var(--ok); }
.stat-note.bad { color: var(--bad); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.page-head .titles { flex: 1 1 300px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.subtitle { color: var(--muted); font-size: 14px; }
.crumbs { font-size: 13.5px; color: var(--muted); }
.crumbs a { color: var(--accent); }
.badge-big { flex: 0 0 56px; height: 56px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-dark); font-size: 20px; font-weight: 650; display: flex; align-items: center; justify-content: center; }
.avatar { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; background: var(--chip); color: var(--text-2); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.avatar.accent { background: var(--accent-soft); color: var(--accent-dark); }
.type-ico { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-dark); display: flex; align-items: center; justify-content: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--chip); color: var(--text-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
a.chip:hover { text-decoration: none; background: #DFE4E8; color: var(--text); }
.chip.on { background: var(--accent); color: #fff; }
.chip.accent { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.chip.ok { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.chip.warn { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.chip.bad { background: var(--bad-bg); color: var(--bad); font-weight: 600; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid #D5DCE1; }
.tab { padding: 10px 14px; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.tab .n { font-size: 12px; color: var(--muted); margin-left: 2px; }

.callout { background: var(--warn-panel); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 16px 20px; display: flex; gap: 14px; color: var(--warn-text); }
.callout .ico { color: var(--warn); margin-top: 1px; }
.callout h2 { font-size: 15px; color: #5C3306; margin-bottom: 4px; }
.callout p { margin: 0; line-height: 1.55; }

.flash { padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-weight: 500; }
.flash.ok { background: var(--ok-bg); border-color: #B7DFC4; color: var(--ok); }
.flash.error { background: var(--bad-bg); border-color: #F0C2C2; color: var(--bad); }
.flash.warn { background: var(--warn-panel); border-color: var(--warn-line); color: var(--warn-text); }
.flash.info { background: var(--accent-soft); border-color: #BFDDDA; color: var(--accent-dark); }

/* key/value grids (asset details, client info) */
.kv { display: flex; flex-wrap: wrap; border-top: 1px solid var(--line); }
.kv > div { flex: 1 1 260px; padding: 12px 20px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kv dt, .kv .k { font-size: 12.5px; color: var(--muted); }
.kv dd, .kv .v { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.kv .v.mono { font-size: 13px; }
.kv-list > div { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 12px 20px; border-top: 1px solid var(--line); }
.kv-list .k { flex: 0 0 150px; color: var(--muted); }
.kv-list .v { flex: 1 1 200px; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }

/* tables */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table.list { width: 100%; border-collapse: collapse; min-width: 640px; }
table.list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); padding: 8px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: var(--panel-2); }
table.list td.mono { font-size: 12.5px; color: var(--text-2); }

/* progress bar for documentation completeness */
progress.bar { width: 100%; height: 6px; border: 0; border-radius: 3px; background: var(--line); overflow: hidden; appearance: none; }
progress.bar::-webkit-progress-bar { background: var(--line); border-radius: 3px; }
progress.bar::-webkit-progress-value { background: var(--accent); border-radius: 3px; }
progress.bar::-moz-progress-bar { background: var(--accent); border-radius: 3px; }
progress.bar.low::-webkit-progress-value { background: #B45309; }
progress.bar.low::-moz-progress-bar { background: #B45309; }

.client-cards { display: flex; flex-wrap: wrap; gap: 16px; }
.client-card { flex: 1 1 250px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; color: var(--text); }
.client-card:hover { text-decoration: none; border-color: var(--line-2); color: var(--text); }
.client-card .name { font-size: 15px; font-weight: 600; }
.progress-label { display: flex; font-size: 12.5px; color: var(--text-2); }
.progress-label span:first-child { flex: 1; }

/* password rows */
.secret { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; color: var(--text-2); background: var(--bg); border-radius: 7px; padding: 7px 10px; overflow-wrap: anywhere; }
.pw-row { display: flex; flex-direction: column; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--line); }
.pw-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pw-top .row-title { flex: 1; }
.pw-line { display: flex; align-items: center; gap: 8px; }
.pw-notes { font-size: 13px; color: var(--text-2); white-space: pre-wrap; background: var(--panel-2); border-radius: 7px; padding: 8px 10px; }

/* documents */
.docs-layout { display: flex; flex-wrap: wrap; align-items: stretch; flex: 1; }
.doc-list { flex: 0 0 320px; background: #FAFBFC; border-right: 1px solid var(--line); padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.doc-list-head { display: flex; align-items: center; gap: 8px; }
.doc-list-head h2 { flex: 1; }
.doc-item { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: 9px; color: var(--text); }
.doc-item:hover { background: #EEF2F4; text-decoration: none; color: var(--text); }
.doc-item.active { background: var(--accent-soft); }
.doc-item .t { font-weight: 500; line-height: 1.35; }
.doc-pane { flex: 999 1 520px; min-width: 0; padding: 28px 40px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 900px; }
.doc-pane h1 { font-size: 30px; }
.content.flush { padding: 0; max-width: none; gap: 0; }

.prose { font-size: 15px; line-height: 1.65; color: #2A333A; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 24px; margin: 28px 0 10px; }
.prose h2 { font-size: 19px; margin: 26px 0 8px; }
.prose h3 { font-size: 16px; margin: 22px 0 6px; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 24px; margin: 0 0 12px; }
.prose li { margin: 4px 0; }
.prose code { background: var(--chip); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.prose pre { position: relative; background: var(--code-bg); color: var(--code-text); border-radius: var(--radius); padding: 16px; overflow-x: auto; font-size: 13px; line-height: 1.7; margin: 0 0 14px; }
.prose pre code { background: none; padding: 0; color: inherit; }
.prose pre .copy-code { position: absolute; top: 8px; right: 8px; height: 28px; padding: 0 10px; border: 1px solid #3A4E5A; border-radius: 6px; background: #17232A; font: inherit; font-family: var(--font); font-size: 12px; font-weight: 500; color: #E5ECEF; cursor: pointer; }
.prose blockquote { margin: 0 0 14px; padding: 12px 16px; background: var(--warn-panel); border: 1px solid var(--warn-line); border-radius: 10px; color: var(--warn-text); }
.prose blockquote p:last-child { margin: 0; }
.prose table { border-collapse: collapse; margin: 0 0 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.prose th { background: var(--panel-2); }
.prose a { text-decoration: underline; }
.prose img { max-width: 100%; }

.audit-row td { font-size: 13px; }
.flush-head { padding: 0 0 4px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field { gap: 10px; }
legend { font-weight: 500; font-size: 13.5px; margin-bottom: 8px; padding: 0; }
#client-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
#client-list legend { grid-column: 1 / -1; }

/* auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.auth-card .brand { color: var(--text); padding: 0; }
.auth-card .brand:hover { color: var(--text); }
.auth-card .form { max-width: none; }
.qr { display: flex; justify-content: center; padding: 8px; }
.qr svg { display: block; width: 100%; max-width: 240px; height: auto; aspect-ratio: 1 / 1; background: #fff; }
.secret-key { font-family: var(--mono); font-size: 15px; letter-spacing: 0.04em; text-align: center; background: var(--bg); border-radius: 9px; padding: 12px; overflow-wrap: anywhere; }
.code-input { font-family: var(--mono) !important; font-size: 22px !important; letter-spacing: 0.3em; text-align: center; }
ol.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--text-2); }

.danger-zone { border-color: #F0C2C2; }
.danger-zone .card-head h2 { color: var(--bad); }

.more-menu .row { min-height: 52px; }

/* ---------------------------------------------------------------- phone */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .session-left, .searchbox kbd { display: none; }
  .new-menu > summary { height: 44px; padding: 0 12px; }
  .searchbox { max-width: none; height: 44px; }
  .content { padding: 16px 16px 96px; gap: 14px; }
  .content.flush { padding: 0 0 80px; }
  h1 { font-size: 21px; }
  .badge-big { flex-basis: 44px; height: 44px; font-size: 17px; border-radius: 12px; }
  .page-head { gap: 12px; align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; height: 44px; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 40px; padding: 0 12px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .row, .pw-row, .card-head { padding-left: 16px; padding-right: 16px; }
  .kv > div { padding: 10px 16px; }
  .kv-list > div { padding: 10px 16px; }
  .kv-list .k { flex-basis: 100%; font-size: 12px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tab { white-space: nowrap; }
  .doc-list { flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .doc-list.has-doc { display: none; }
  .doc-pane { padding: 18px 16px 32px; }
  .doc-pane h1 { font-size: 23px; }
  .stat { flex-basis: calc(50% - 8px); padding: 14px 16px; }
  .stat-value { font-size: 26px; }
  .auth-card { padding: 24px 20px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 500; color: var(--muted); }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a.active { color: var(--accent-dark); }
}
@media (min-width: 861px) {
  .phone-only { display: none !important; }
}
