/* Stringer-App Admin Portal */
:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1d2733;
    --muted: #5d6b7a;
    --line: #d9e0e7;
    --brand: #1f4e79;
    --brand-dark: #163a5c;
    --brand-soft: #e7eef6;
    --ok-bg: #e8f5ec;
    --ok-text: #1d5e33;
    --error-bg: #fdecec;
    --error-text: #8a1c1c;
    --warn: #9a5b00;
    --warn-bg: #fff4e0;
    --radius: 8px;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    color: var(--text);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12171d;
        --surface: #1b222b;
        --text: #e4e9ee;
        --muted: #9aa8b6;
        --line: #2e3945;
        --brand: #6fa8dc;
        --brand-dark: #8dbbe6;
        --brand-soft: #22303f;
        --ok-bg: #173323;
        --ok-text: #9ddcb0;
        --error-bg: #3a1c1c;
        --error-text: #f2a9a9;
        --warn: #f0b860;
        --warn-bg: #3a2c14;
    }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: 0 0 .3rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .5rem; }
code { background: var(--brand-soft); padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Top bar */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    background: var(--brand-dark); color: #fff; padding: .7rem 1.25rem;
}
@media (prefers-color-scheme: dark) { .topbar { background: #0c1117; border-bottom: 1px solid var(--line); } }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand span { font-weight: 400; opacity: .8; margin-left: .3rem; }
.who { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.who a, .who .link { color: #fff; }
.company-pill { background: rgba(255,255,255,.16); padding: .2rem .65rem; border-radius: 999px; font-weight: 600; }
.user { opacity: .9; }

/* Layout */
.shell { display: flex; min-height: calc(100vh - 52px); }
.sidenav { width: 200px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .6rem; display: flex; flex-direction: column; gap: 2px; }
.sidenav a, .sidenav .soon { display: block; padding: .5rem .75rem; border-radius: 6px; text-decoration: none; color: var(--text); }
.sidenav a:hover { background: var(--brand-soft); }
.sidenav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sidenav .soon { color: var(--muted); cursor: default; }
.sidenav .soon small { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; margin-left: .3rem; }
.content { flex: 1; padding: 1.5rem 2rem 3rem; max-width: 1150px; min-width: 0; }
.content.narrow { margin: 0 auto; max-width: 440px; padding-top: 4rem; }

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidenav { width: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: .5rem; }
    .content { padding: 1rem; }
    .content.narrow { padding-top: 1.5rem; }
}

/* Cards, notices, tiles */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem; }
.notice { border-radius: var(--radius); padding: .75rem 1rem; margin: 0 0 1rem; }
.notice ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.notice.ok { background: var(--ok-bg); color: var(--ok-text); }
.notice.error { background: var(--error-bg); color: var(--error-text); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: 1.6rem; font-weight: 700; }
.tile-note { color: var(--muted); font-size: .85rem; }
.tile-note.warn { color: var(--warn); font-weight: 600; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .2rem 0; }

/* Forms */
label { display: block; font-weight: 600; margin: .9rem 0 .3rem; }
input, textarea, select {
    width: 100%; font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid #aab6c2; border-radius: 6px; padding: .5rem .6rem;
}
@media (prefers-color-scheme: dark) { input, textarea, select { border-color: #4a5868; } }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
input.short { max-width: 10rem; }
input[type=checkbox] { width: auto; margin: 0 .4rem 0 0; }
label.check { display: flex; align-items: center; font-weight: 400; margin: .9rem 0 .2rem; }
.hint { color: var(--muted); font-size: .88rem; margin: .35rem 0 0; }
.form fieldset { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem 1.2rem 1.2rem; margin: 0 0 1rem; }
.form legend { font-weight: 700; padding: 0 .4rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
@media (max-width: 760px) { .grid3 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: .6rem; margin-top: 1.2rem; }
.admin-rows { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; }
.admin-row { display: grid; grid-template-columns: 2fr 1.2fr 1.2fr 7.5rem 7rem; gap: .5rem; align-items: center; }
.admin-row.head { font-size: .82rem; color: var(--muted); font-weight: 600; }
.admin-row label.check { margin: 0; justify-content: center; }
@media (max-width: 760px) { .admin-row { grid-template-columns: 1fr 1fr; } .admin-row.head { display: none; } }

/* Buttons */
button, .button {
    display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
    padding: .5rem 1rem; border-radius: 6px; border: 1px solid #aab6c2; background: var(--surface); color: var(--text);
}
button:hover, .button:hover { border-color: var(--brand); }
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary, .button.primary { color: #0c1117; } }
button.primary:hover, .button.primary:hover { background: var(--brand-dark); }
button.link { background: none; border: 0; padding: 0; font-weight: 400; text-decoration: underline; color: var(--brand); }
form.inline { display: inline; margin: 0; }
.signin form > button.primary { width: 100%; margin-top: 1.2rem; padding: .65rem; }
.secondary-action { margin-top: 1rem; text-align: center; }

/* Tables */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--bg); }
tbody tr:last-child td { border-bottom: 0; }
tr.current td { background: var(--brand-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
table.compact th, table.compact td { padding: .35rem .5rem; }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand); margin-left: .35rem; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.crumbs { margin: 0 0 .3rem; color: var(--muted); }
.tile-link { margin-top: .35rem; font-size: .88rem; }
ul.columns { columns: 3 14rem; }

/* Versions */
.notice.confirm { background: var(--warn-bg); color: var(--text); border: 1px solid var(--warn); display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.notice.confirm p { margin: 0; flex-basis: 100%; }
.create-version { margin: 1rem 0; padding: 1rem 1.2rem; }
.create-version h2 { margin-top: 0; }
.create-version form { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; }
.create-version label { flex-basis: 100%; margin: 0; }
.create-version input { flex: 1; min-width: 14rem; }
.no-margin { margin: 0; }
.small { font-size: .82rem; }
.notes-form { display: flex; gap: .4rem; min-width: 16rem; }
.notes-form button { padding: .35rem .7rem; }
.notes-form input { padding: .35rem .5rem; }
.tag.ok { background: var(--ok-bg); color: var(--ok-text); margin-left: 0; }
table.versions td.status { white-space: nowrap; }

/* Users */
.pool { color: var(--muted); }
.search { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 1rem 0 0; }
.search input { max-width: 22rem; }
table.users th.center, table.users td.center { text-align: center; }
table.users th.pick, table.users td.pick { width: 2rem; }
a.sort { color: var(--muted); text-decoration: none; }
a.sort.active { color: var(--text); }
button.link.small { display: block; margin: .2rem auto 0; font-size: .78rem; }
button.danger { color: var(--error-text); border-color: var(--error-text); }
button.danger:hover { background: var(--error-bg); }
.add-users { margin-top: 1.6rem; }
.user-rows { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; }
.user-row { display: grid; grid-template-columns: 2fr 1.2fr 1.2fr 6.5rem 7.5rem 7rem; gap: .5rem; align-items: center; }
.user-row.no-license { grid-template-columns: 2fr 1.2fr 1.2fr 7.5rem 7rem; }
.user-row.head { font-size: .82rem; color: var(--muted); font-weight: 600; }
.user-row label.check { margin: 0; justify-content: center; }
@media (max-width: 760px) { .user-row, .user-row.no-license { grid-template-columns: 1fr 1fr; } .user-row.head { display: none; } }
.nowrap { white-space: nowrap; }
.tag.muted-tag { background: var(--bg); color: var(--muted); border: 1px solid var(--line); margin-left: 0; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }

/* Company page blocks */
.block { margin-top: 1.6rem; }
.block h2 { margin: 0 0 .5rem; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.block-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1.1rem; }
.block-body.domains { min-height: 3.2rem; }
.push-right { margin-left: auto; }

/* Add users window */
dialog.add-users-dialog {
    width: min(1100px, 96vw); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
dialog.add-users-dialog::backdrop { background: rgba(10, 20, 30, .45); }
dialog.add-users-dialog form { padding: 1rem 1.4rem 1.2rem; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--surface); padding: .4rem 0; z-index: 1; }
.dialog-head h2 { margin: 0; }
dialog.add-users-dialog .form-actions { position: sticky; bottom: 0; background: var(--surface); padding: .8rem 0 .2rem; margin-top: .8rem; border-top: 1px solid var(--line); }
dialog.add-users-dialog .user-row input { padding: .35rem .5rem; }
.settings-form { display: flex; flex-wrap: wrap; align-items: end; gap: .4rem 1.4rem; }
.settings-form label { margin-top: 0; }

/* Conductors */
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 1rem; }
.grid3 .span2 { grid-column: span 2; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0 1rem; }
.checks label.check { margin: .5rem 0 0; }
table.conductors td { vertical-align: top; }
@media (max-width: 760px) { .grid4 { grid-template-columns: 1fr 1fr; } .grid3 .span2 { grid-column: auto; } }
input:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }

/* Sag & Tension */
.upload-form { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.upload-form input[type=file] { width: auto; flex: 1; min-width: 16rem; padding: .35rem; }
.notice.warn { background: var(--warn-bg); color: var(--text); border: 1px solid var(--warn); }
.preview .form-actions { align-items: center; margin: .6rem 0 1rem; }
dl.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .6rem 1.2rem; margin: 0 0 .6rem; }
dl.facts dt { color: var(--muted); font-size: .82rem; }
dl.facts dd { margin: 0; font-weight: 600; }
details.span-table { margin: .4rem 0; }
details > summary { cursor: pointer; padding: .3rem 0; font-weight: 600; }
table.sag tr.loaded td { background: var(--brand-soft); }
.sag-table { margin-bottom: .8rem; }
.sag-table-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }

/* Records */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem 1rem 1rem; margin-top: 1rem; }
.filters label { margin-top: .5rem; }
.filters input, .filters select { width: auto; min-width: 10rem; }
.filter-actions { display: flex; gap: .5rem; }
.pager { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
table.records td { vertical-align: top; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 0 1.2rem; }
p.big { font-size: 1.25rem; font-weight: 700; }
