/* KeyHarbor – visual system
   Harbor ink sidebar, cool slate page, brass as the single accent (keys, rings, primary action).
   The memorable element is the launcher "key tag" card; everything else stays quiet. */

@font-face { font-family: "Plex"; src: url("../vendor/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../vendor/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../vendor/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --kh-ink: #13283b;
  --kh-ink-2: #1c3850;
  --kh-ink-text: #c9d6e2;
  --kh-page: #eef2f5;
  --kh-surface: #ffffff;
  --kh-line: #d8e0e7;
  --kh-text: #1b2733;
  --kh-muted: #5d6e7e;
  --kh-brass: #c8902e;
  --kh-brass-deep: #a87420;
  --kh-link: #1f5f8b;
  --kh-danger: #b4372f;
  --kh-ok: #2f7d4f;
  --kh-radius-tag: 14px;
  --kh-radius: 8px;
  --bs-body-font-family: "Plex", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-color: var(--kh-text);
  --bs-body-bg: var(--kh-page);
  --bs-link-color-rgb: 31, 95, 139;
  --bs-border-color: var(--kh-line);
}

body { background: var(--kh-page); color: var(--kh-text); font-size: 0.9375rem; line-height: 1.55; font-feature-settings: "tnum" 1; }
h1, .h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.01em; }
h2, .h2 { font-size: 1.15rem; font-weight: 600; }
h3, .h3 { font-size: 1rem; font-weight: 600; }
.text-muted, .kh-muted { color: var(--kh-muted) !important; }
a { color: var(--kh-link); }
:focus-visible { outline: 3px solid var(--kh-brass); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(200, 144, 46, .35); border-color: var(--kh-brass); }
.visually-hidden-focusable:focus { position: fixed !important; top: 8px; left: 8px; z-index: 2000; background: #fff; padding: 8px 12px; }

/* Buttons: brass is reserved for the primary action on a screen */
.btn-primary { --bs-btn-bg: var(--kh-brass); --bs-btn-border-color: var(--kh-brass); --bs-btn-hover-bg: var(--kh-brass-deep); --bs-btn-hover-border-color: var(--kh-brass-deep); --bs-btn-active-bg: var(--kh-brass-deep); --bs-btn-color: #1b1406; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; font-weight: 500; }
.btn-outline-primary { --bs-btn-color: var(--kh-link); --bs-btn-border-color: #9db6ca; --bs-btn-hover-bg: var(--kh-link); --bs-btn-hover-border-color: var(--kh-link); }
.btn-ink { background: var(--kh-ink); color: #fff; border-color: var(--kh-ink); }
.btn-ink:hover { background: var(--kh-ink-2); color: #fff; }

/* Shell */
.kh-shell { display: flex; min-height: 100vh; }
.kh-sidebar { width: 248px; flex: 0 0 248px; background: var(--kh-ink); color: var(--kh-ink-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.kh-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; text-decoration: none; font-weight: 600; font-size: 1.05rem; }
.kh-brand:hover { color: #fff; }
.kh-mark { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--kh-brass); position: relative; flex: 0 0 auto; }
.kh-mark::after { content: ""; position: absolute; left: 50%; top: 100%; width: 3px; height: 9px; background: var(--kh-brass); transform: translateX(-50%); }
.kh-nav { padding: 4px 10px 20px; }
.kh-nav-group { font-size: .78rem; color: #8ea4b8; padding: 16px 12px 6px; }
.kh-nav a { display: flex; align-items: center; gap: 10px; color: var(--kh-ink-text); text-decoration: none; padding: 7px 12px; border-radius: 6px; font-size: .9rem; }
.kh-nav a:hover { background: var(--kh-ink-2); color: #fff; }
.kh-nav a[aria-current="page"] { background: var(--kh-ink-2); color: #fff; box-shadow: inset 3px 0 0 var(--kh-brass); }
.kh-nav .bi { font-size: 1rem; opacity: .85; }
.kh-sidebar-foot { margin-top: auto; padding: 14px 20px 18px; border-top: 1px solid #22415c; font-size: .82rem; }
.kh-sidebar-foot .kh-user { color: #fff; font-weight: 500; }
.kh-main { flex: 1 1 auto; min-width: 0; }
.kh-topbar { display: none; }
.kh-content { max-width: 1240px; padding: 28px 32px 56px; }
.kh-pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.kh-pagehead p { margin: 4px 0 0; color: var(--kh-muted); max-width: 70ch; }

@media (max-width: 991.98px) {
  .kh-sidebar { position: fixed; z-index: 1040; left: 0; transform: translateX(-100%); transition: transform .2s ease; }
  .kh-sidebar.show { transform: none; }
  .kh-topbar { display: flex; align-items: center; justify-content: space-between; background: var(--kh-ink); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 1030; }
  .kh-topbar .kh-brand { padding: 0; }
  .kh-content { padding: 20px 16px 48px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Panels and tables */
.kh-panel { background: var(--kh-surface); border: 1px solid var(--kh-line); border-radius: var(--kh-radius); }
.kh-panel > .kh-panel-head { padding: 14px 18px; border-bottom: 1px solid var(--kh-line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kh-panel > .kh-panel-head h2 { margin: 0; font-size: 1rem; }
.kh-panel > .kh-panel-body { padding: 18px; }
.kh-panel + .kh-panel { margin-top: 20px; }
.table { --bs-table-bg: transparent; margin-bottom: 0; font-size: .9rem; }
.table > thead th { font-weight: 500; color: var(--kh-muted); border-bottom-color: var(--kh-line); white-space: nowrap; font-size: .82rem; }
.table > :not(caption) > * > * { padding: .6rem .75rem; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-hover-bg: #f5f8fa; }
.kh-badge { font-weight: 500; }
.form-label { font-weight: 500; font-size: .88rem; margin-bottom: .3rem; }
.form-text { color: var(--kh-muted); }
.kh-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kh-filters .form-control, .kh-filters .form-select { width: auto; min-width: 160px; }
.kh-stat { padding: 16px 18px; }
.kh-stat .kh-stat-n { font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.kh-stat .kh-stat-l { color: var(--kh-muted); font-size: .85rem; }
.kh-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kh-dl dt { font-weight: 500; color: var(--kh-muted); }
.kh-dl dd { margin: 0; overflow-wrap: anywhere; }
.kh-flags .form-check { margin-right: 14px; }
.kh-empty { text-align: center; padding: 48px 20px; color: var(--kh-muted); }
.kh-empty .bi { font-size: 2rem; color: #9db0c0; display: block; margin-bottom: 8px; }
.kh-code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: .04em; }
.kh-codes { columns: 2; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; list-style: none; padding: 0; }
.kh-secret-once { background: #fff8ea; border: 1px solid #ecd3a3; border-radius: var(--kh-radius); padding: 16px 18px; }
.kh-danger-zone { border-color: #e6bfbb; }
.kh-danger-zone > .kh-panel-head h2 { color: var(--kh-danger); }

/* Launcher: key-tag cards — the one distinctive element */
.kh-keyboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.kh-tag { position: relative; background: var(--kh-surface); border: 1px solid var(--kh-line); border-radius: var(--kh-radius-tag) var(--kh-radius-tag) var(--kh-radius-tag) 44px; padding: 18px 18px 16px 22px; display: flex; flex-direction: column; min-height: 196px; }
.kh-tag::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 4px; border-radius: 0 3px 3px 0; background: var(--tag, var(--kh-link)); }
.kh-tag-ring { position: absolute; top: 14px; right: 14px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--kh-line); background: var(--kh-page); }
.kh-tag-head { display: flex; gap: 12px; align-items: center; padding-right: 26px; }
.kh-appicon { width: 44px; height: 44px; border-radius: 10px; flex: 0 0 44px; display: grid; place-items: center; color: #fff; font-weight: 600; background: var(--tag, var(--kh-link)); overflow: hidden; }
.kh-appicon img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.kh-appicon.lg { width: 64px; height: 64px; flex-basis: 64px; font-size: 1.3rem; border-radius: 14px; }
.kh-tag h2 { font-size: 1rem; margin: 0; line-height: 1.3; }
.kh-tag h2 a { color: var(--kh-text); text-decoration: none; }
.kh-tag h2 a:hover { text-decoration: underline; }
.kh-tag .kh-tag-cat { font-size: .82rem; color: var(--kh-muted); }
.kh-tag p { color: var(--kh-muted); font-size: .88rem; margin: 12px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kh-tag-actions { margin-top: auto; padding-top: 14px; display: flex; gap: 8px; align-items: center; }
.kh-tag.is-maintenance { opacity: .75; }

/* Credential rows on the app page */
.kh-account { border: 1px solid var(--kh-line); border-radius: var(--kh-radius); padding: 14px 16px; background: var(--kh-surface); }
.kh-account + .kh-account { margin-top: 12px; }
.kh-field { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; }
.kh-field + .kh-field { border-top: 1px dashed var(--kh-line); }
.kh-field .kh-field-l { color: var(--kh-muted); font-size: .85rem; }
.kh-value { font-family: ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; min-height: 1.5em; }
.kh-value.is-revealed { background: #fff8ea; border-radius: 4px; padding: 0 6px; }
.kh-countdown { font-size: .78rem; color: var(--kh-brass-deep); margin-left: 6px; }
@media (max-width: 575.98px) { .kh-field { grid-template-columns: 1fr; } }

/* Guest (sign-in) layout */
.kh-guest { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, 420px) 1fr; }
.kh-guest-side { background: var(--kh-ink); color: var(--kh-ink-text); padding: 40px 36px; display: flex; flex-direction: column; }
.kh-guest-side .kh-brand { padding: 0; font-size: 1.2rem; }
.kh-guest-side .kh-guest-note { margin-top: auto; font-size: .88rem; max-width: 36ch; }
.kh-guest-side .kh-guest-note strong { color: #fff; font-weight: 500; }
.kh-guest-main { display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.kh-guest-card { width: 100%; max-width: 420px; }
.kh-guest-card.wide { max-width: 760px; }
.kh-guest-card h1 { margin-bottom: 6px; }
@media (max-width: 767.98px) { .kh-guest { grid-template-columns: 1fr; } .kh-guest-side { padding: 20px 16px; } .kh-guest-side .kh-guest-note { display: none; } }

/* Toasts */
.kh-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.kh-toast { background: var(--kh-ink); color: #fff; border-radius: 8px; padding: 10px 14px; font-size: .9rem; box-shadow: 0 6px 20px rgba(19, 40, 59, .25); }
.kh-toast.is-error { background: var(--kh-danger); }

/* Mini chart */
.kh-bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.kh-bars .kh-bar { flex: 1; display: flex; flex-direction: column-reverse; gap: 2px; min-width: 0; }
.kh-bars .kh-bar span { display: block; border-radius: 2px 2px 0 0; }
.kh-bars .ok { background: #8fb3cf; }
.kh-bars .bad { background: var(--kh-danger); }
.kh-bars-legend { font-size: .8rem; color: var(--kh-muted); display: flex; gap: 14px; margin-top: 8px; }
.kh-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }

.kh-qr { background: #fff; padding: 10px; border: 1px solid var(--kh-line); border-radius: 8px; display: inline-block; }
.kh-qr img { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.pagination { --bs-pagination-active-bg: var(--kh-ink); --bs-pagination-active-border-color: var(--kh-ink); --bs-pagination-color: var(--kh-link); }
.kh-help h2 { margin-top: 1.6rem; }
.kh-help { max-width: 72ch; }
.kh-help li { margin-bottom: .35rem; }
.kh-inline-form { display: inline; }
.kh-swatch { width: 44px; padding: 2px; height: 38px; }
.kh-nowrap { white-space: nowrap; }
.kh-matrix th, .kh-matrix td { text-align: center; }
.kh-matrix th:first-child, .kh-matrix td:first-child { text-align: left; }

/* Application tones (CSP forbids inline styles) */
.kh-tone-0 { --tag: #2f5d8a; }
.kh-tone-1 { --tag: #1f7a6d; }
.kh-tone-2 { --tag: #6a4c93; }
.kh-tone-3 { --tag: #b4572f; }
.kh-tone-4 { --tag: #3d7a2f; }
.kh-tone-5 { --tag: #8a2f5d; }
.kh-tone-6 { --tag: #2f6f8a; }
.kh-tone-7 { --tag: #7a6a1f; }
.kh-tone-8 { --tag: #4a5568; }
.kh-tone-9 { --tag: #a3392b; }
.kh-tone-10 { --tag: #23527c; }
.kh-tone-11 { --tag: #5b7a1f; }
.kh-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.kh-swatches label { width: 30px; height: 30px; border-radius: 6px; background: var(--tag); cursor: pointer; display: grid; place-items: center; }
.kh-swatches input { position: absolute; opacity: 0; }
.kh-swatches input:checked + label { outline: 3px solid var(--kh-ink); outline-offset: 2px; }
.kh-swatches input:focus-visible + label { outline: 3px solid var(--kh-brass); outline-offset: 2px; }
.kh-narrow { max-width: 480px; }
.ok-dot { background: #8fb3cf; } .bad-dot { background: var(--kh-danger); }
.form-control, .form-select { background-color: #fff; }
.kh-tag { min-height: 176px; }
@media (max-width: 575.98px) { .kh-tag { min-height: 0; } }
.kh-sso-chip { display: inline-block; font-size: .75rem; font-weight: 500; color: var(--kh-ok); margin-right: 4px; }
