/* KCMP portal styles — emerald navigation, slim fixed header, scrolling body. */

:root {
    --ink: #142a20;
    --muted: #63736a;
    --bg: #f4f7f5;
    --surface: #ffffff;
    --border: #e1e9e4;
    --hairline: #edf2ef;
    --primary: #0f7a50;
    --primary-ink: #0b5e3d;
    --primary-soft: #e4f3ea;
    --sidebar-top: #0c5039;
    --sidebar-bottom: #073b29;
    --sidebar-ink: #d8ebe0;
    --sidebar-muted: #9fc4b0;
    --sidebar-active: #17704e;
    --focus: #1f9d63;
    --radius: 14px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg); }
h1, h2, h3 { color: var(--ink); }
button, input, select { font: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.icon { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; padding: 8px 12px; background: #fff; border-radius: 8px; }
.skip-link:focus { left: 12px; }
code { font-family: var(--mono); font-size: 12px; background: var(--hairline); padding: 1px 4px; border-radius: 4px; }

/* Shell */
.shell { display: flex; height: 100vh; height: 100dvh; }
.sidebar { width: 248px; flex: none; display: flex; flex-direction: column; padding: 14px 12px; overflow-y: auto; color: var(--sidebar-ink); background: linear-gradient(180deg, var(--sidebar-top), var(--sidebar-bottom)); transition: width .18s ease; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 14px; margin-bottom: 10px; border-bottom: 1px solid rgba(255, 255, 255, .09); color: #fff; text-decoration: none; }
.brand-arms { width: 42px; height: 42px; flex: none; display: grid; place-items: center; background: #fff; border-radius: 10px; }
.brand-arms img { width: 34px; height: auto; }
.brand-arms-lg { width: 64px; height: 64px; border-radius: 14px; border: 1px solid var(--border); }
.brand-arms-lg img { width: 54px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 18px; letter-spacing: .03em; }
.brand-text span { font-size: 12px; line-height: 1.25; color: var(--sidebar-ink); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: none; color: var(--sidebar-ink); text-align: left; text-decoration: none; cursor: pointer; white-space: nowrap; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.is-active { background: var(--sidebar-active); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(0, 0, 0, .18); }
.nav-chevron { margin-left: auto; opacity: .7; }
.nav-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .1); }
.nav-collapse { color: var(--sidebar-muted); font-size: 13px; }
.sidebar-backdrop { display: none; }

@media (min-width: 901px) {
    html[data-sidebar="collapsed"] .sidebar { width: 72px; }
    html[data-sidebar="collapsed"] .brand-text,
    html[data-sidebar="collapsed"] .nav-label,
    html[data-sidebar="collapsed"] .nav-chevron { display: none; }
    html[data-sidebar="collapsed"] .brand,
    html[data-sidebar="collapsed"] .nav-link { justify-content: center; }
    html[data-sidebar="collapsed"] .nav-collapse .icon { transform: rotate(180deg); }
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .menu-btn { display: none; }
.crumbs { font-size: 13px; color: var(--muted); white-space: nowrap; }
.crumb-sep { margin: 0 6px; }
.crumb-current { color: var(--primary-ink); font-weight: 600; }
.search { flex: 0 1 460px; margin: 0 auto; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: #f8faf9; color: var(--muted); }
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 122, 80, .15); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); }
.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: #33463c; cursor: pointer; }
.icon-btn:hover { background: #eff4f1; }
.when-fullscreen { display: none; }
html.is-fullscreen .when-fullscreen { display: inline; }
html.is-fullscreen .when-windowed { display: none; }
.avatar-btn { display: flex; align-items: center; gap: 4px; padding: 2px 4px 2px 2px; border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #0f6b47; color: #fff; font-size: 13px; font-weight: 600; }

.dropdown { position: relative; }
.dropdown-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 42, 30, .14); }
.dropdown-panel p { margin: 0 0 6px; }
.dropdown-title { font-weight: 600; }
.dropdown-link { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: none; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; }
.dropdown-link:hover { background: #f1f6f3; }

.content { flex: 1; overflow-y: auto; padding: 18px 24px 12px; outline: none; }
.page-foot { margin-top: 18px; padding-top: 10px; color: var(--muted); font-size: 12px; }
.flash { margin: 0 0 12px; padding: 8px 12px; border: 1px solid #cfe7d8; border-radius: 10px; background: #ecf7f0; color: var(--primary-ink); }

/* Page parts */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-head h1 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -.01em; }
.lead { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.page-date { margin: 0; color: var(--muted); white-space: nowrap; }

.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border: 1px solid var(--primary); border-radius: 10px; background: var(--primary); color: #fff; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer; }
.btn:hover { background: var(--primary-ink); }
.btn-outline { background: #fff; color: var(--primary-ink); }
.btn-outline:hover { background: var(--primary-soft); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }
.btn-small { height: 30px; padding: 0 10px; font-size: 13px; }
.link { display: inline-flex; align-items: center; gap: 4px; color: var(--primary-ink); font-size: 13px; font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }

.banner { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; padding: 14px 18px; border: 1px solid #cfe7d8; border-radius: var(--radius); background: #ecf7f0; }
.banner-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #1c7a52; color: #fff; }
.banner-text { flex: 1 1 240px; min-width: 0; }
.banner-text h2 { margin: 0; font-size: 16px; }
.banner-text p { margin: 2px 0 0; color: var(--muted); }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.col-main, .col-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }

.panel { padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-tools { display: flex; align-items: center; gap: 10px; }
.panel-foot { margin: 12px 0 0; font-size: 12.5px; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: #f7f9f8; }
.segmented a { padding: 5px 12px; border-radius: 8px; color: var(--muted); font-size: 13px; text-decoration: none; }
.segmented a.is-on { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.view-toggle { display: inline-flex; gap: 4px; }
.view-toggle button { width: 32px; height: 30px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer; }
.view-toggle button.is-on { background: #0f6b47; border-color: #0f6b47; color: #fff; }
.inline-search { flex: 1 1 320px; max-width: 460px; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 3px 0 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--muted); }
.inline-search:focus-within { border-color: var(--primary); }
.inline-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); }

/* Application cards */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.app-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; transition: box-shadow .15s ease; }
.app-card:hover { box-shadow: 0 4px 14px rgba(16, 42, 30, .07); }
.app-icon { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 12px; }
.app-body h3 { margin: 0; font-size: 15px; }
.app-summary { margin: 2px 0 6px; color: var(--muted); font-size: 13px; }
.app-action { margin-top: auto; font-size: 13px; }
.app-fav { position: absolute; top: 10px; right: 10px; }
.star { display: grid; place-items: center; padding: 4px; border: 0; border-radius: 6px; background: none; color: #9aa8a0; cursor: pointer; }
.star:hover { color: #a87a00; background: #fbf5e3; }
.star.is-on { color: #e0a400; }
.star.is-on .icon { fill: currentColor; }
.state { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa8a0; }
.state-pending_setup .dot { background: #d39b12; }
.state-link_only .dot { background: #2f66d0; }
.state-unavailable .dot { background: #c0392b; }
.app-grid[data-view="list"] { grid-template-columns: 1fr; gap: 8px; }
.app-grid[data-view="list"] .app-card { flex-direction: row; align-items: center; gap: 14px; padding: 10px 14px; }
.app-grid[data-view="list"] .app-icon { width: 40px; height: 40px; }
.app-grid[data-view="list"] .app-body { flex: 1; display: grid; grid-template-columns: minmax(160px, 1.2fr) minmax(0, 1.5fr) 140px; align-items: center; gap: 12px; }
.app-grid[data-view="list"] .app-summary { margin: 0; }
.app-grid[data-view="list"] .app-action { margin: 0; min-width: 190px; }
.app-grid[data-view="list"] .app-fav { position: static; }

.tone-green { background: #e3f4e9; color: #1a7f48; }
.tone-blue { background: #e5eefc; color: #2f66d0; }
.tone-purple { background: #efe7fb; color: #7a3fd1; }
.tone-orange { background: #fdeedd; color: #b5650a; }
.tone-sky { background: #e3eefb; color: #1a5fc0; }
.tone-emerald { background: #dff3ea; color: #0c7a4f; }

/* Lists, states, facts */
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 12px; color: var(--muted); text-align: center; }
.empty .icon { color: #9db3a6; }
.empty p { margin: 0; max-width: 52ch; }
.empty-sm { padding: 12px 8px; }
.quick-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.quick-list a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--ink); text-decoration: none; }
.quick-list a:hover { background: #f5f9f7; border-color: #cfe2d6; }
.quick-list span { flex: 1; }
.status-box { display: flex; gap: 12px; padding: 12px; border-radius: 10px; }
.status-box p { margin: 2px 0 0; font-size: 13px; }
.status-unknown { background: #f3f5f4; border: 1px solid var(--border); color: var(--muted); }
.status-unknown strong { color: var(--ink); }

.facts { margin: 0; }
.facts > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-active { background: #e3f4e9; color: #17663f; }
.badge-pending, .badge-warn { background: #fff4dc; color: #8a5a00; }
.badge-suspended, .badge-retired { background: #fde8e8; color: #9b1c1c; }

.notice { display: flex; gap: 12px; margin-bottom: 16px; padding: 14px 16px; border-radius: var(--radius); }
.notice > div { flex: 1; min-width: 0; }
.notice h2 { margin: 0 0 2px; font-size: 16px; }
.notice p { margin: 0 0 10px; }
.notice-warn { background: #fff8e8; border: 1px solid #f1d9a6; color: #6b4500; }
.notice-warn h2 { color: #5a3a00; }
.notice .table { background: rgba(255, 255, 255, .65); border-radius: 8px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 600; text-align: left; }
.table td { padding: 7px 8px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }

/* Admin forms (identity links) */
.queue-item { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--hairline); }
.queue-item:last-child { border-bottom: 0; }
.queue-facts { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 320px; }
.pin-display { margin: 4px 0 12px; font-size: 32px; font-weight: 700; letter-spacing: .3em; }
.hint { margin-top: 4px; padding: 4px 8px; border-radius: 8px; background: #fff8e8; color: #6b4500; font-size: 12.5px; }
.inline-form > summary { list-style: none; cursor: pointer; }
.inline-form > summary::-webkit-details-marker { display: none; }
.inline-form[open] > summary { margin-bottom: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; min-width: min(560px, 100%); }
.form-grid label, .stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.form-grid input, .form-grid textarea, .stack input { padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; font-weight: 400; background: #fff; }
.form-grid textarea { resize: vertical; }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 6px; min-width: 220px; }
.actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.panel-summary { cursor: pointer; }
.panel-summary h2 { display: inline; margin: 0; font-size: 17px; }

@media (max-width: 700px) {
    .form-grid { grid-template-columns: 1fr; min-width: 0; }
    .span-2 { grid-column: auto; }
}

/* Sign-in */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--sidebar-top), #062f21); }
.auth-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 24px; background: var(--surface); border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.auth-card p { margin: 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.auth-brand h1 { margin: 0; font-size: 22px; }
.auth-title { margin: 0; font-size: 20px; }
.auth-brand p { color: var(--muted); }
.alert { padding: 8px 12px; border: 1px solid #f5c2c2; border-radius: 10px; background: #fdecec; color: #8a1c1c; }
.dev-panel { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px dashed #c3d8ca; border-radius: 12px; background: #f7faf8; }
.dev-panel h2 { margin: 0; font-size: 14px; }
.dev-panel form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.dev-panel label { font-size: 13px; font-weight: 600; }
.dev-panel select { height: 36px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

/* Responsive */
@media (max-width: 1180px) {
    .overview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 264px; transform: translateX(-100%); transition: transform .2s ease; }
    html.nav-open .sidebar { transform: none; }
    html.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .35); }
    .nav-collapse { display: none; }
    .topbar .menu-btn { display: grid; }
    .topbar { gap: 8px; padding: 0 12px; }
    .crumbs { display: none; }
    .search { margin: 0; flex: 1 1 auto; }
    .content { padding: 14px 16px 10px; }
    .two-col { grid-template-columns: 1fr; }
    .page-head { flex-direction: column; align-items: flex-start; gap: 4px; }
    .banner { flex-wrap: wrap; }
    .app-grid[data-view="list"] .app-body { grid-template-columns: 1fr; gap: 2px; }
    .app-grid[data-view="list"] .app-action { min-width: 0; }
}

@media (max-width: 560px) {
    .topbar-actions [data-action="fullscreen"] { display: none; }
    .page-head h1 { font-size: 22px; }
    .facts > div { grid-template-columns: 1fr; gap: 2px; }
    .app-grid { grid-template-columns: 1fr; }
    .app-grid[data-view="list"] .app-card { flex-wrap: wrap; }
}
