/* SharePro Data Service - one stylesheet, no framework. Light and dark follow the system setting. */
:root {
    --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8fafc; --ink: #0f172a; --ink-2: #334155; --muted: #64748b;
    --line: #e2e8f0; --line-strong: #cbd5e1;
    --accent: #2563eb; --accent-ink: #ffffff; --accent-soft: #eff4ff; --accent-strong: #1d4ed8;
    --ok: #15803d; --ok-soft: #e8f6ee; --warn: #b45309; --warn-soft: #fef5e6; --bad: #b91c1c; --bad-soft: #fdecec;
    --side-bg: #0f172a; --side-ink: #cbd5e1; --side-muted: #64748b; --side-active: #1e293b;
    --radius: 10px; --radius-sm: 7px;
    --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 1px 3px rgb(15 23 42 / .05);
    --shadow-lg: 0 10px 30px rgb(15 23 42 / .12);
    --side-w: 260px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --ink: #e5e7eb; --ink-2: #cbd5e1; --muted: #94a3b8;
        --line: #1f2937; --line-strong: #334155;
        --accent: #3b82f6; --accent-soft: #172554; --accent-strong: #60a5fa;
        --ok: #4ade80; --ok-soft: #052e16; --warn: #fbbf24; --warn-soft: #2d1a03; --bad: #f87171; --bad-soft: #2c0b0b;
        --side-bg: #020617; --side-active: #111c33;
        --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-lg: 0 10px 30px rgb(0 0 0 / .5);
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; margin: 0 0 .35rem; }
h2 { font-size: 1.1rem; font-weight: 650; margin: 0 0 .75rem; }
.muted { color: var(--muted); margin: 0 0 1.25rem; }
.icon { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- app frame ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 30;
    display: flex; flex-direction: column; background: var(--side-bg); color: var(--side-ink);
    transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand strong, .login-brand strong { display: block; font-size: 1rem; line-height: 1.1; }
.brand small, .login-brand small { display: block; color: var(--side-muted); font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: #fff;
    background: linear-gradient(135deg, #3b82f6, #6366f1); box-shadow: 0 4px 14px rgb(59 130 246 / .35); }
.sidebar nav { flex: 1; overflow-y: auto; padding: .5rem .75rem; }
.nav-label { margin: 1.1rem .75rem .4rem; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; margin: 2px 0; border-radius: var(--radius-sm);
    color: var(--side-ink); font-weight: 500; }
.sidebar nav a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #3b82f6; }
.sidebar nav a.active .icon { color: #60a5fa; }
.user-box { display: flex; align-items: center; gap: .65rem; margin: .75rem; padding: .65rem; border-radius: var(--radius); background: var(--side-active); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none;
    background: #334155; color: #fff; font-weight: 600; font-size: .8rem; }
.user-name { flex: 1; min-width: 0; color: #fff; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name small { display: block; color: #93c5fd; font-size: .72rem; font-weight: 500; }
.user-box .icon-button { color: var(--side-ink); }
.user-box .icon-button:hover { background: #334155; color: #fff; }

.shell { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: none; align-items: center; gap: .5rem; height: 56px; padding: 0 1rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-title { font-weight: 600; }
.content { width: 100%; padding: 2rem 2.25rem 3rem; }   /* lists use the full width; forms keep their own max-width */
.scrim { display: none; }

.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px;
    background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-button:hover { background: var(--surface-2); }

/* ---------- page parts ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }

.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); border: 1px solid; margin: 0 0 1rem; }
.alert.success { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.alert.danger, p.error, ul.error { background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
    color: var(--bad); padding: .75rem 1rem; border-radius: var(--radius-sm); margin: 0 0 1rem; }
ul.error { padding-left: 2rem; }

/* toolbar above a list: filters left, actions right */
.filter { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin: 1rem 0 1.25rem; padding: 1rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.filter > label:not(.check) { min-width: 160px; }
.filter > a.button:first-of-type { margin-left: auto; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th, td { padding: .65rem .85rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 600;
    letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { color: var(--muted); text-align: center; padding: 2.5rem 1rem; }
td a { font-weight: 500; white-space: nowrap; }
td a + a { margin-left: .75rem; }
tr.detail td { padding-top: 0; color: var(--muted); font-size: 12px; border-bottom-color: var(--line-strong); }
tr.detail span + span::before { content: "·"; margin: 0 .5rem; }
tbody tr:has(+ tr.detail) td { border-bottom: 0; }
tbody tr:has(+ tr.detail):hover td, tbody tr:has(+ tr.detail):hover + tr.detail td { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.rows td { padding: .4rem .35rem; }
.rows input { width: 100%; min-width: 5.5rem; }

.badge, .tag { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .55rem; border-radius: 999px;
    font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.tag { background: var(--accent-soft); color: var(--accent-strong); border-radius: 6px; letter-spacing: .02em; }

.pager { display: flex; align-items: center; gap: .75rem; color: var(--muted); margin-top: 1rem; }
.pager a { padding: .35rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }

/* ---------- forms ---------- */
.edit, .result, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.5rem; max-width: 1040px; margin-top: 1rem; }
.result { margin-top: 1.25rem; }
.result ul { margin: 0 0 1rem; padding-left: 1.2rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .25rem 1.25rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field small { color: var(--muted); font-size: .78rem; }
.field .error { color: var(--bad); font-size: .8rem; font-weight: 500; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; color: var(--ink-2); font-size: .85rem; }
label.check { flex-direction: row; align-items: center; gap: .55rem; font-weight: 500; cursor: pointer; }
.field label.check { margin-top: .2rem; }

input, select, textarea {
    font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); padding: .55rem .7rem; min-height: 40px; width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); margin: 0; }
input[type="file"] { padding: .45rem; background: var(--surface-2); border-style: dashed; cursor: pointer; }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; margin-right: .75rem; padding: .35rem .8rem; border: 0;
    border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); cursor: pointer; }
textarea { min-height: 90px; resize: vertical; }
select { appearance: none; padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .7rem center; }
.filter input, .filter select { min-height: 38px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem .25rem; margin: .5rem 0 1.25rem; }
legend { padding: 0 .4rem; font-weight: 600; color: var(--ink-2); }
[hidden] { display: none !important; }

/* ---------- buttons (button, .button, .btn share one look) ---------- */
button, .button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 38px; padding: .5rem 1rem;
    font: inherit; font-weight: 600; font-size: 14px; line-height: 1; white-space: nowrap; cursor: pointer;
    color: var(--accent-ink); background: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgb(37 99 235 / .25); transition: background .15s, box-shadow .15s, transform .05s;
}
button:hover, .button:hover, .btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); text-decoration: none; }
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); box-shadow: none; }
button.secondary:hover, .button.secondary:hover { background: var(--surface-2); border-color: var(--muted); }
button.danger { background: var(--surface); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); box-shadow: none; margin-left: auto; }
button.danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
button.link { min-height: 0; padding: 0; background: none; border: 0; box-shadow: none; color: var(--accent); font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; }
.btn.block { width: 100%; }
.icon-button, .icon-button:hover { min-height: 0; box-shadow: none; border: 0; }
.buttons { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }

/* ---------- details (corporate action, industry) ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.25rem; align-items: baseline; margin: 1rem 0;
    padding: 1.1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-width: 1040px; }
.edit .facts { background: var(--surface-2); box-shadow: none; }
.facts dt { font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
@media (min-width: 900px) { .facts { grid-template-columns: max-content 1fr max-content 1fr; } }

/* ---------- home ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.tile { display: flex; gap: 1rem; align-items: flex-start; padding: 1.25rem; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
.tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.tile-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex: none; background: var(--accent-soft); color: var(--accent); }
.tile-icon .icon { width: 22px; height: 22px; }
.tile-text strong { display: block; margin-bottom: .2rem; }
.tile-text span { color: var(--muted); font-size: .88rem; }

/* ---------- login ---------- */
.public { min-height: 100vh; background:
    radial-gradient(1100px 500px at 10% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgb(99 102 241 / .16), transparent 60%), var(--bg); }
.public-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 400px; padding: 2rem; background: var(--surface); border: 1px solid var(--line);
    border-radius: 16px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 1.35rem; margin-top: 1.5rem; }
.login-brand { display: flex; align-items: center; gap: .75rem; }
.login-brand small { color: var(--muted); }
.login-foot { color: var(--muted); font-size: .8rem; margin-top: 1.25rem; }

/* ---------- small screens ---------- */
@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.menu-open .sidebar { transform: none; }
    body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgb(15 23 42 / .45); }
    .shell { margin-left: 0; }
    .topbar { display: flex; }
    .content { padding: 1.25rem 1rem 2.5rem; }
    h1 { font-size: 1.3rem; }
}
@media (max-width: 640px) {
    .filter { flex-direction: column; align-items: stretch; }
    .filter > label:not(.check) { min-width: 0; }
    .filter > a.button:first-of-type { margin-left: 0; }
    .edit, .result { padding: 1.1rem; }
    .buttons > * { flex: 1; }
    button.danger { margin-left: 0; }
    th, td { padding: .55rem .65rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.code { display: block; color: var(--muted); font-size: 11.5px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
td.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }

/* sortable column headings (site.js) */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: "\2195"; margin-left: .35rem; opacity: .35; font-size: .85em; }
th.sortable[aria-sort="ascending"], th.sortable[aria-sort="descending"] { color: var(--accent); }
th.sortable[aria-sort="ascending"]::after { content: "\2191"; opacity: 1; }
th.sortable[aria-sort="descending"]::after { content: "\2193"; opacity: 1; }

/* a filter field that takes the free room of the toolbar (search boxes) */
.filter > label.grow { flex: 1 1 380px; max-width: 640px; }

/* intro text under a page title: readable line length */
.content > p { max-width: 95ch; color: var(--muted); margin: 0 0 1rem; }

/* file boxes of the import screens (_FileField) */
.file-field { gap: .3rem; padding: 1rem 1.1rem; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface-2); transition: border-color .15s, background .15s; }
.file-field:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.file-field:focus-within { border-color: var(--accent); background: var(--surface); }
.file-title { display: flex; align-items: center; gap: .6rem; font-weight: 600; color: var(--ink); font-size: .92rem; }
.file-hint { color: var(--muted); font-size: .8rem; font-weight: 400; margin-bottom: .45rem; }
.file-field input[type="file"] { background: var(--surface); }
.edit > .alert, .edit > p.error { margin-top: .5rem; }

/* company logo on the login card; the logo has dark lettering, so it sits on white in dark mode too */
.login-logo { display: flex; justify-content: center; padding-bottom: 1.4rem; margin-bottom: 1.4rem; border-bottom: 1px solid var(--line); }
.login-logo img { display: block; height: 50px; width: auto; }
@media (prefers-color-scheme: dark) {
    .login-logo img { background: #fff; padding: .4rem .8rem; border-radius: 10px; box-sizing: content-box; }
}
.login-card .login-brand .brand-mark { width: 32px; height: 32px; border-radius: 8px; }
.login-card .login-brand .brand-mark .icon { width: 18px; height: 18px; }
.login-card h1 { margin-top: 1.25rem; }
