/* Tall Ship adapter — operator portal.
   Deliberately small and dependency-free: no build step, no CDN, no framework. */

:root {
    --ink: #16202a;
    --ink-soft: #5b6b7a;
    --ink-faint: #8798a6;
    --line: #dde4ea;
    --line-soft: #eef2f5;
    --bg: #f4f7f9;
    --panel: #ffffff;
    --accent: #10556b;
    --accent-ink: #ffffff;
    --ok: #1c7c4a;
    --ok-bg: #e6f4ec;
    --warn: #8a5a00;
    --warn-bg: #fdf2dc;
    --bad: #a3282d;
    --bad-bg: #fbe9ea;
    --radius: 6px;
    --sidebar-w: 218px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- shell: fixed sidebar, scrolling content ---------- */

.shell { display: flex; align-items: flex-start; min-height: 100vh; }

.sidebar {
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    align-self: stretch;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--accent);
    color: var(--accent-ink);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    gap: 22px;
}

/* min-width:0 is load-bearing: without it a wide table stretches the flex item
   instead of scrolling inside its own .scroll-x container. */
.content { flex: 1; min-width: 0; }
.content-inner { max-width: 1120px; margin: 0 auto; padding: 26px 28px 0; }

.brand {
    font-weight: 700;
    letter-spacing: .2px;
    white-space: nowrap;
    color: var(--accent-ink);
    text-decoration: none;
    padding: 0 8px;
    font-size: 16px;
}
.brand:hover { opacity: .85; }
.brand span { font-weight: 400; opacity: .7; }
.brand-lg { font-size: 20px; color: var(--accent); display: block; margin-bottom: 20px; text-align: center; padding: 0; }

.sidenav { display: flex; flex-direction: column; gap: 1px; }
.sidenav a {
    color: rgba(255, 255, 255, .82);
    text-decoration: none;
    padding: 7px 10px;
    border-radius: var(--radius);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidenav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.sidenav a.is-active { background: rgba(255, 255, 255, .18); color: #fff; font-weight: 600; }

.sidenav-group {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .9px;
    color: rgba(255, 255, 255, .45);
    padding: 16px 10px 5px;
}

/* Pinned to the bottom of the sidebar on tall viewports. */
.whoami {
    margin-top: auto;
    padding: 14px 10px 4px;
    border-top: 1px solid rgba(255, 255, 255, .16);
    font-size: 13px;
    color: rgba(255, 255, 255, .85);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 9px;
}
.whoami-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.foot { color: var(--ink-faint); font-size: 12px; padding-top: 8px; padding-bottom: 32px; }
.foot code { background: #e7edf1; padding: 1px 4px; border-radius: 3px; }

/* Narrow viewports: the sidebar becomes a normal banner above the content and
   the nav wraps horizontally. No JS, so nothing to toggle and nothing to break. */
@media (max-width: 860px) {
    .shell { flex-direction: column; align-items: stretch; }
    .sidebar {
        flex: none;
        width: auto;
        position: static;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px 16px;
        padding: 12px 16px;
    }
    .sidenav { flex-direction: row; flex-wrap: wrap; gap: 4px; flex: 1; }
    .sidenav-group { display: none; }
    .whoami {
        margin-top: 0;
        padding: 0;
        border-top: 0;
        flex-direction: row;
        align-items: center;
    }
    .content-inner { padding: 20px; }
}

/* ---------- page header ---------- */

.page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.page-head h1 { font-size: 21px; margin: 0; }
.page-head .actions { display: flex; gap: 8px; }
.page-note { color: var(--ink-soft); font-size: 13px; margin: 0 0 18px; max-width: 78ch; }
.page-note code { background: #e7edf1; padding: 1px 4px; border-radius: 3px; }

/* ---------- panel ---------- */

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.panel-head {
    padding: 11px 16px;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--ink-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.panel-body { padding: 16px; }

/* ---------- tables ---------- */

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 9px 16px; text-align: left; vertical-align: top; }
table.grid thead th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ink-faint);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.grid tbody tr + tr td { border-top: 1px solid var(--line-soft); }
table.grid tbody tr:hover { background: #fafcfd; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.row-actions { text-align: right; white-space: nowrap; }
table.grid td.row-actions form { display: inline; }
.is-dim td { opacity: .55; }

.empty { padding: 28px 16px; text-align: center; color: var(--ink-faint); font-size: 14px; }

/* Wide tables scroll rather than blowing out the page. */
.scroll-x { overflow-x: auto; }

code, .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
}

/* ---------- definition list (detail views) ---------- */

dl.facts { margin: 0; display: grid; grid-template-columns: minmax(150px, 220px) 1fr; }
dl.facts dt {
    padding: 7px 16px 7px 0;
    color: var(--ink-faint);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-top: 1px solid var(--line-soft);
}
dl.facts dd { margin: 0; padding: 7px 0; border-top: 1px solid var(--line-soft); overflow-wrap: anywhere; }
dl.facts dt:first-of-type, dl.facts dd:first-of-type { border-top: 0; }
dl.facts dd.none { color: var(--ink-faint); }

/* ---------- badges ---------- */

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .3px;
    white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-mute { background: #eceff2; color: var(--ink-soft); }

/* ---------- stat tiles ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.tile {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
    display: block;
}
.tile:hover { border-color: #c3d0da; }
/* These are spans in the markup, so they need display:block to stack. */
.tile .n { display: block; font-size: 27px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .k { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-faint); margin-top: 2px; }
.tile .sub { display: block; font-size: 12.5px; color: var(--ink-soft); margin-top: 7px; min-height: 1.2em; }
.tile .sub.alert { color: var(--bad); font-weight: 600; }

/* ---------- forms ---------- */

.form-narrow { max-width: 620px; }
.input { margin-bottom: 15px; }
.input label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.input input[type=text],
.input input[type=email],
.input input[type=password],
.input select,
.input textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    background: #fff;
    color: var(--ink);
}
.input input:focus, .input select:focus, .input textarea:focus {
    outline: 2px solid rgba(16, 85, 107, .35);
    outline-offset: -1px;
    border-color: var(--accent);
}
.input.checkbox label { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; color: var(--ink); }
.input.checkbox input { width: auto; }
.input .error-message { color: var(--bad); font-size: 12.5px; margin-top: 4px; }
.input.error input, .input.error select { border-color: var(--bad); }
.hint { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; }

.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters .input { margin-bottom: 0; }
.filters .input input, .filters .input select { min-width: 180px; width: auto; }
.filters .input.checkbox { padding-bottom: 8px; }

.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.form-actions .spacer { flex: 1; }

/* ---------- buttons ---------- */

.btn {
    display: inline-block;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn-quiet { background: transparent; border-color: rgba(255, 255, 255, .4); color: inherit; }
.btn-quiet:hover { background: rgba(255, 255, 255, .14); filter: none; }
.btn-plain { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-plain:hover { background: #f6f9fb; filter: none; border-color: #c3d0da; }
.btn-danger { background: #fff; border-color: var(--line); color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); filter: none; border-color: var(--bad); }
.btn-sm { padding: 3px 9px; font-size: 12.5px; }

/* ---------- flash ---------- */

.message {
    padding: 11px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
}
.message.success { background: var(--ok-bg); color: var(--ok); border-color: #bfe0cd; }
.message.error { background: var(--bad-bg); color: var(--bad); border-color: #f0c6c8; }
.message.warning { background: var(--warn-bg); color: var(--warn); border-color: #ecd7a6; }
.message.info { background: #e8f1f5; color: var(--accent); border-color: #c6dbe4; }

/* ---------- pagination ---------- */

.pager { display: flex; gap: 6px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.pager a, .pager .current {
    padding: 3px 9px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--accent);
}
.pager .current { background: var(--accent); color: #fff; font-weight: 600; }
.pager .disabled { color: var(--ink-faint); padding: 3px 9px; }
.pager .counter { margin-left: auto; color: var(--ink-faint); }

/* ---------- login ---------- */

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-shell { width: 100%; max-width: 380px; }
.login-shell .panel { margin-bottom: 0; }

/* ---------- API log bodies ---------- */

.log-h {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ink-faint);
    margin: 14px 0 6px;
}
.log-h:first-child { margin-top: 0; }

.logbody {
    background: #f7f9fb;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 11px 13px;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
    max-height: 340px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ---------- one-time secret reveal ---------- */

.reveal {
    background: #10202a;
    color: #7fd8a8;
    padding: 16px;
    border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 15px;
    word-break: break-all;
    user-select: all;
}
