/*
   Athavita licence portal.

   One stylesheet, no build step and no framework. This application is a handful
   of tables and forms used by a handful of people; a toolchain would be more
   moving parts than the thing it builds.

   Tokens are defined once on :root for light and redefined for dark, so a colour
   never has its only definition inside a media query.
*/

:root {
    color-scheme: light dark;

    --ink:        #14181d;
    --ink-2:      #4a545f;
    --ink-3:      #78838f;
    --ground:     #f4f5f3;
    --surface:    #ffffff;
    --line:       #dfe2df;
    --line-soft:  #ebeeeb;

    /* One accent, spent carefully: a deep spruce that reads as considered
       rather than corporate-blue, with a warm amber for the only thing on these
       screens that is genuinely urgent. */
    --accent:     #1f5f52;
    --accent-ink: #ffffff;
    --accent-sub: #e6efec;

    --good:       #2a6b45;
    --good-sub:   #e4f0e8;
    --warn:       #8a5a12;
    --warn-sub:   #faf0dd;
    --bad:        #8f2f2a;
    --bad-sub:    #f8e6e5;
    --quiet-sub:  #eceeec;

    --radius: 6px;
    --shadow: 0 1px 2px rgb(20 24 29 / 6%), 0 6px 18px -12px rgb(20 24 29 / 22%);

    --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink:        #e8ebe8;
        --ink-2:      #a6b0ab;
        --ink-3:      #7d8884;
        --ground:     #10130f;
        --surface:    #191d1a;
        --line:       #2c322e;
        --line-soft:  #232823;

        --accent:     #64b8a3;
        --accent-ink: #06110e;
        --accent-sub: #17302a;

        --good:       #74c193;
        --good-sub:   #16291d;
        --warn:       #d6a44f;
        --warn-sub:   #2c2415;
        --bad:        #e08b84;
        --bad-sub:    #2e1a19;
        --quiet-sub:  #232823;

        --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 20px -14px rgb(0 0 0 / 70%);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font: 15px/1.55 var(--sans);
    -webkit-font-smoothing: antialiased;
}

/* ----------------------------------------------------------------- masthead */

.masthead {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.wordmark {
    display: flex;
    align-items: baseline;
    gap: 7px;
    text-decoration: none;
    padding: 15px 0;
    white-space: nowrap;
}

.wordmark-a { font-weight: 700; letter-spacing: -0.015em; color: var(--ink); }
.wordmark-b { color: var(--accent); font-weight: 500; }

.masthead nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }

.masthead nav a {
    padding: 17px 13px 15px;
    color: var(--ink-2);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    font-weight: 500;
}

.masthead nav a:hover { color: var(--ink); background: var(--line-soft); }
.masthead nav a.on { color: var(--accent); border-bottom-color: var(--accent); }

.who { display: flex; align-items: center; gap: 14px; color: var(--ink-3); font-size: 13px; }

/* -------------------------------------------------------------------- strips */

.strip {
    padding: 11px 16px;
    border-left: 3px solid;
    font-size: 14px;
}

.strip-ok   { background: var(--good-sub); border-color: var(--good); color: var(--good); }
.strip-bad  { background: var(--bad-sub);  border-color: var(--bad);  color: var(--bad); }
.strip-warn { background: var(--warn-sub); border-color: var(--warn); color: var(--warn); }

main { padding: 26px 24px 60px; max-width: 1240px; margin: 0 auto; }
main.bare { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

main > .strip { margin-bottom: 20px; border-radius: var(--radius); }

/* --------------------------------------------------------------------- pages */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.page-head h1 { margin: 0 0 4px; font-size: 25px; letter-spacing: -0.02em; text-wrap: balance; }
.page-head p  { margin: 0; color: var(--ink-2); max-width: 68ch; }

h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -0.01em; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 20px; }
.card > h2:first-child { margin-top: 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; }
.stat .n { font-size: 27px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); font-weight: 600; }
.stat.is-warn .n { color: var(--warn); }
.stat.is-bad .n  { color: var(--bad); }

/* -------------------------------------------------------------------- tables */

.scroller { overflow-x: auto; margin: 0 -18px -18px; padding: 0 18px 18px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    font-weight: 600;
    padding: 0 12px 8px 0;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--line-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; }
td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.mono  { font-family: var(--mono); font-size: 12.5px; }

/* --------------------------------------------------------------------- pills */

.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.pill-active     { background: var(--good-sub);   color: var(--good); }
.pill-pending    { background: var(--accent-sub); color: var(--accent); }
.pill-expiring   { background: var(--warn-sub);   color: var(--warn); }
.pill-expired    { background: var(--quiet-sub);  color: var(--ink-3); }
.pill-superseded { background: var(--quiet-sub);  color: var(--ink-3); }
.pill-revoked    { background: var(--bad-sub);    color: var(--bad); }

/* --------------------------------------------------------------------- forms */

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--ink-2); }
label .hint { display: block; font-weight: 400; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }

/* Everything except the inputs that are their own control. Written this way
   round because `input` with no type attribute IS a text box, and a selector
   listing types silently misses it - which is a field rendered at its default
   size next to identical fields that are not. */
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=submit]):not([type=button]),
select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

textarea { min-height: 72px; resize: vertical; }

.field { margin-bottom: 15px; }
.fields { display: grid; gap: 0 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Side-by-side fields whose labels wrap to different heights would otherwise
   put their inputs at different heights, which reads as a broken form. The
   label takes the slack, so the boxes line up along the bottom of the row. */
.fields > .field { display: flex; flex-direction: column; }
.fields > .field > label { flex: 1; }

.checks { display: grid; gap: 7px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; }
.check label { margin: 0; font-weight: 400; color: var(--ink); }

button, .btn {
    display: inline-block;
    padding: 8px 15px;
    border-radius: var(--radius);
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

button:hover, .btn:hover { filter: brightness(1.08); }
button[disabled] { opacity: 0.45; cursor: not-allowed; filter: none; }

.btn-quiet, button.quiet {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
}

.btn-danger, button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }

button.link {
    background: none;
    border: 0;
    color: var(--accent);
    padding: 0;
    font-weight: 500;
    text-decoration: underline;
    cursor: pointer;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 18px;
}

.filters .field { margin: 0; min-width: 160px; }

/* --------------------------------------------------------------------- token */

.token {
    font-family: var(--mono);
    font-size: 12px;
    /* Both a licence key, which is one unbroken string and must wrap anywhere,
       and a worked example of configuration, which is JSON and is unreadable
       without its own line breaks. */
    white-space: pre-wrap;
    word-break: break-all;
    background: var(--ground);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    line-height: 1.5;
    max-height: 190px;
    overflow-y: auto;
}

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; padding-top: 2px; }
dl.facts dd { margin: 0; }

.empty { padding: 34px 20px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink-2); margin-bottom: 4px; }

.note {
    background: var(--accent-sub);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 13.5px;
    color: var(--ink-2);
}

.note strong { color: var(--ink); }

footer {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 24px 30px;
    color: var(--ink-3);
    font-size: 12.5px;
}

/* --------------------------------------------------------------------- login */

.signin { width: min(400px, 100%); }
.signin .card { padding: 26px; }
.signin h1 { font-size: 21px; margin: 0 0 6px; }
.signin p.lede { margin: 0 0 20px; color: var(--ink-2); font-size: 14px; }
.signin button { width: 100%; margin-top: 4px; }

@media (max-width: 720px) {
    .masthead { flex-wrap: wrap; gap: 0 18px; padding: 0 16px; }
    .masthead nav { order: 3; width: 100%; overflow-x: auto; }
    .masthead nav a { padding: 11px 10px; }
    main { padding: 20px 16px 50px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------------- setup */

main.wide { max-width: 780px; }

.setup-head { margin-bottom: 24px; }
.setup-head h1 { margin: 0 0 8px; font-size: 27px; letter-spacing: -0.02em; }
.setup-head p { margin: 0; color: var(--ink-2); max-width: 62ch; }

.setup .card + .card { margin-top: 18px; }

.setup h2 {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 16px;
}

/* The step number reads as an ordinal, which is true here — this really is a
   sequence, and each part depends on the one before it. */
.setup h2::first-letter { color: var(--accent); }

ul.steps { margin: 14px 0; padding-left: 0; list-style: none; }

ul.steps li {
    padding: 6px 0 6px 24px;
    position: relative;
    font-size: 14px;
    color: var(--ink-2);
    border-bottom: 1px solid var(--line-soft);
}

ul.steps li:last-child { border-bottom: 0; }
ul.steps li::before { content: "✓"; position: absolute; left: 2px; color: var(--good); font-weight: 700; }

/* The one destructive thing on this screen. Folded away, and coloured as a
   warning rather than as an accent, so it does not read as a normal option
   somebody works through on the way to Install. */
details.danger-zone {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--warn);
    border-radius: var(--radius);
    padding: 12px 14px;
    background: var(--warn-sub);
}

details.danger-zone > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--warn);
}

details.danger-zone[open] > summary { margin-bottom: 10px; }
details.danger-zone p { margin: 0 0 8px; color: var(--ink-2); }
details.danger-zone .check label { color: var(--ink-2); }

/* Some messages from the setup wizard are two paragraphs: what to do about the
   problem, then the database's own words for whoever has to search for them. */
.strip { white-space: pre-line; }
