/* ===========================================================================
   Licence Allotment - a small, dense, keyboard-friendly staff tool.

   Hand-written rather than a framework: this app is two lists and three forms,
   and a component library would cost every operator a download for widgets it
   never uses. Everything below is one screen's worth of CSS.
   =========================================================================== */

:root {
    --ink:        #1b2430;
    --ink-soft:   #5a6472;
    --ink-faint:  #8b95a3;
    --line:       #dfe4ea;
    --line-soft:  #eef1f5;
    --paper:      #ffffff;
    --ground:     #f4f6f9;
    --brand:      #1f5f8b;
    --brand-dark: #17496b;
    --brand-tint: #e8f1f8;
    --good:       #17795e;
    --good-tint:  #e4f3ee;
    --warn:       #9a6400;
    --warn-tint:  #fdf1dc;
    --bad:        #b3261e;
    --bad-tint:   #fbeae9;
    --radius:     6px;
    --shadow:     0 1px 2px rgba(20,30,45,.06), 0 4px 12px rgba(20,30,45,.05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--ground);
    color: var(--ink);
    font: 15px/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.35rem; margin: 0 0 .2rem; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; font-weight: 600; }
h3 { font-size: .82rem; margin: 1.4rem 0 .5rem; font-weight: 700;
     text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
a  { color: var(--brand); }

.boot { padding: 3rem; text-align: center; color: var(--ink-faint); }
.muted { color: var(--ink-soft); }
.small { font-size: .82rem; }
.num   { font-variant-numeric: tabular-nums; text-align: right; }
.mono  { font-family: "Cascadia Mono", Consolas, "SF Mono", monospace; font-size: .82rem; }

/* ── shell ───────────────────────────────────────────────────────────────── */

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 1rem;
    background: var(--brand-dark); color: #fff;
    padding: .55rem 1.1rem;
}
.topbar .brand { font-weight: 600; letter-spacing: -.01em; }
.topbar nav { display: flex; gap: .3rem; margin-left: 1rem; }
.topbar nav a {
    color: #cfe0ec; text-decoration: none; padding: .35rem .7rem;
    border-radius: var(--radius); font-size: .9rem;
}
.topbar nav a:hover  { background: rgba(255,255,255,.1); color: #fff; }
.topbar nav a.active { background: rgba(255,255,255,.18); color: #fff; }
/* Grouped navigation. Hover-opened rather than click-opened: a click menu needs
   a second click to close, and something then has to decide what counts as
   "outside". The group head is focusable so the menu opens from the keyboard
   too - :focus-within covers tabbing into it. */
.navgroup { position: relative; display: inline-block; }
.navgroup-head {
    display: inline-block; color: #cfe0ec; padding: .35rem .7rem;
    border-radius: var(--radius); font-size: .9rem; cursor: default; user-select: none;
}
.navgroup-head::after { content: " \25BE"; opacity: .7; }
.navgroup:hover .navgroup-head,
.navgroup:focus-within .navgroup-head { background: rgba(255,255,255,.1); color: #fff; }

.navgroup-menu {
    display: none; position: absolute; top: 100%; left: 0; z-index: 40;
    min-width: 210px; padding: .25rem;
    background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.navgroup:hover .navgroup-menu,
.navgroup:focus-within .navgroup-menu { display: block; }

.topbar nav .navgroup-menu a {
    display: block; color: var(--ink); padding: .4rem .6rem; font-size: .88rem;
}
.topbar nav .navgroup-menu a:hover,
.topbar nav .navgroup-menu a.active { background: var(--brand-tint); color: var(--brand-dark); }

.topbar .spacer { flex: 1; }
.topbar .who { font-size: .85rem; color: #cfe0ec; }
.topbar .who b { color: #fff; font-weight: 600; }

/* Says which licence server you are editing. Loud on purpose. */
.env-badge {
    background: #b3261e; color: #fff; font-size: .7rem; font-weight: 700;
    letter-spacing: .08em; padding: .18rem .45rem; border-radius: 3px;
}

.main { flex: 1; padding: 1.2rem; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ── surfaces ────────────────────────────────────────────────────────────── */

.card {
    background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem; margin-bottom: 1rem;
}
.page-head { display: flex; align-items: flex-end; gap: 1rem; margin-bottom: .9rem; }
.page-head .spacer { flex: 1; }

/* ── controls ────────────────────────────────────────────────────────────── */

label { display: block; font-size: .78rem; font-weight: 600;
        color: var(--ink-soft); margin-bottom: .22rem; }

input[type=text], input[type=password], input[type=number],
input[type=date], select, textarea {
    width: 100%; padding: .42rem .55rem;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: #fff; color: var(--ink); font: inherit;
}
input[type=number], .field-num input { text-align: right; font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint);
}
textarea { min-height: 62px; resize: vertical; }

.hint { font-size: .74rem; color: var(--ink-faint); margin-top: .2rem; }

.grid { display: grid; gap: .8rem 1rem; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 860px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

.check { display: flex; align-items: center; gap: .45rem; }
.check input { width: auto; }
.check label { margin: 0; font-weight: 500; color: var(--ink); font-size: .9rem; }

.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .9rem; border: 1px solid var(--line);
    background: #fff; color: var(--ink); border-radius: var(--radius);
    font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--line-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn.danger  { color: var(--bad); border-color: #eccdcb; }
.btn.danger:hover:not(:disabled) { background: var(--bad-tint); }
.btn.small   { padding: .22rem .55rem; font-size: .8rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* The legal-document type switcher. Four buttons in two groups - the full
   licence pair and the demonstration pair - so it is obvious at a glance
   which audience the document being edited is actually served to. */
.doc-group-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-faint);
    white-space: nowrap;
}

.doc-group-sep {
    width: 1px;
    align-self: stretch;
    min-height: 1.4rem;
    background: var(--line);
    margin: 0 .3rem;
}

/* ── tables ──────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
    text-align: left; font-size: .72rem; text-transform: uppercase;
    letter-spacing: .05em; color: var(--ink-faint); font-weight: 700;
    padding: .45rem .55rem; border-bottom: 2px solid var(--line);
    white-space: normal;
}
td { padding: .45rem .55rem; border-bottom: 1px solid var(--line-soft); }
tbody tr:hover { background: var(--brand-tint); }
tbody tr.clickable { cursor: pointer; }
tr.is-blocked td { background: var(--bad-tint); }
tr.is-blocked:hover td { background: #f7dedc; }

/* ── status ──────────────────────────────────────────────────────────────── */

.banner { padding: .6rem .8rem; border-radius: var(--radius);
          border: 1px solid; margin-bottom: .9rem; font-size: .9rem; }
.banner.error { background: var(--bad-tint);  border-color: #eccdcb; color: var(--bad); }
.banner.ok    { background: var(--good-tint); border-color: #c9e5db; color: var(--good); }
.banner.warn  { background: var(--warn-tint); border-color: #ecd9ae; color: var(--warn); }

.pill { display: inline-block; padding: .1rem .45rem; border-radius: 99px;
        font-size: .72rem; font-weight: 600; }
.pill.ok    { background: var(--good-tint); color: var(--good); }
.pill.warn  { background: var(--warn-tint); color: var(--warn); }
.pill.bad   { background: var(--bad-tint);  color: var(--bad); }
.pill.plain { background: var(--line-soft); color: var(--ink-soft); }

/* ── modules ─────────────────────────────────────────────────────────────── */

.mod-group { margin-bottom: 1rem; }
.mod-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: .35rem; }
.mod {
    display: flex; align-items: flex-start; gap: .5rem;
    padding: .4rem .55rem; border: 1px solid var(--line);
    border-radius: var(--radius); background: #fff;
}
.mod:hover { border-color: var(--brand); }
.mod.on { background: var(--brand-tint); border-color: #b9d4e6; }
.mod input { width: auto; margin-top: .2rem; }
.mod .name { font-size: .88rem; font-weight: 500; }
.mod .code { font-size: .7rem; color: var(--ink-faint); }

/* ── admin area and reports ──────────────────────────────────────────────── */

/* The freshly generated batch. Monospaced and scrollable so a run of 500 can be
   selected and copied in one go without the card growing to a metre tall. */
.serial-dump {
    max-height: 230px; overflow: auto; white-space: pre;
    padding: .6rem .7rem; background: var(--ground);
    border: 1px solid var(--line); border-radius: var(--radius);
    line-height: 1.5; user-select: all;
}

/* The module whose customer list is open below. */
tr.selected-row td { background: var(--brand-tint); }
tr.selected-row:hover td { background: #dceaf4; }

/* Module code under the module name. */
.code { font-family: "Cascadia Mono", Consolas, "SF Mono", monospace; font-size: .7rem; }

/* Filter bars put a select next to a text box next to a check box; without this
   the selects stretch to the full row and push everything else onto its own
   line. */
.btn-row select, .btn-row input[type=text] { width: auto; }

/* ── sign in ─────────────────────────────────────────────────────────────── */

.signin { max-width: 380px; margin: 8vh auto; }
.signin .card { padding: 1.6rem; }
.signin h1 { margin-bottom: 1.1rem; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: #fdf1dc; color: #9a6400; padding: .7rem 1.1rem;
    border-top: 1px solid #ecd9ae;
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; font-size: 1.1rem; }

/* ── entitlement ledgers ─────────────────────────────────────────────────── */

/* One panel per ledger, side by side. Bordered rather than another .card,
   because they belong to the licence card they sit inside and a nested shadow
   reads as a separate thing. */
.ledger {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: .7rem .8rem; background: var(--paper);
}
.ledger-head {
    display: flex; align-items: center; gap: .5rem;
    font-weight: 600; font-size: .9rem; margin-bottom: .5rem;
    padding-bottom: .4rem; border-bottom: 1px solid var(--line-soft);
}
.ledger-head .spacer { flex: 1; }

/* The total. Large enough to be the thing you read first, because on an
   existing licence it is the answer and the rows are the working. */
.ledger-total { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

/* An entry dated in the future: recorded, not yet counted. */
tr.pending-row td { background: var(--warn-tint); }

/* A reduction. Coloured so a negative reads as one at a glance rather than
   depending on the minus sign being noticed. */
.qty-down { color: var(--bad); }

/* ── the staff manual ────────────────────────────────────────────────────── */

/* Contents beside the text rather than above it, so the reader can see where
   they are in a long document without scrolling back. It collapses to a plain
   list on a narrow screen, where a sticky column would eat the page. */
.manual { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.4rem; }
@media (max-width: 860px) { .manual { grid-template-columns: 1fr; } }

.manual-toc {
    position: sticky; top: 1rem; align-self: start;
    background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: .6rem;
}
@media (max-width: 860px) { .manual-toc { position: static; } }

.manual-toc-head {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--ink-faint); font-weight: 700; padding: .2rem .5rem .45rem;
}
.manual-toc a {
    display: block; padding: .32rem .5rem; border-radius: var(--radius);
    font-size: .85rem; color: var(--ink); text-decoration: none;
}
.manual-toc a:hover { background: var(--line-soft); }
.manual-toc a.here  { background: var(--brand-tint); color: var(--brand-dark); font-weight: 600; }

/* Each section is its own card, so where one ends and the next begins is
   obvious at a glance in a document this long. */
.manual-body section {
    background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.1rem 1.3rem; margin-bottom: 1rem;

    /* Sticky table of contents would otherwise cover the heading of whatever
       section was just jumped to. */
    scroll-margin-top: 1rem;
}
.manual-body h2 { font-size: 1.1rem; margin-bottom: .7rem; }
.manual-body h3 { margin-top: 1.5rem; }
.manual-body p  { margin: 0 0 .8rem; max-width: 68ch; }
.manual-body ul, .manual-body ol { margin: 0 0 .8rem; padding-left: 1.2rem; max-width: 68ch; }
.manual-body li { margin-bottom: .45rem; }
.manual-body table { margin-bottom: .3rem; }

/* The numbered walkthrough. Bigger markers than a plain list, because these are
   steps to be followed in order rather than points to be read. */
ol.steps { counter-reset: step; list-style: none; padding-left: 0; }
ol.steps > li {
    counter-increment: step; position: relative;
    padding: .1rem 0 .8rem 2.4rem; margin: 0;
}
ol.steps > li::before {
    content: counter(step);
    position: absolute; left: 0; top: 0;
    width: 1.7rem; height: 1.7rem; border-radius: 50%;
    background: var(--brand); color: #fff;
    font-size: .82rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* The things somebody will otherwise learn the hard way. */
.callout {
    background: var(--brand-tint); border-left: 3px solid var(--brand);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: .7rem .9rem; margin: 0 0 .9rem; font-size: .9rem; max-width: 68ch;
}
.callout.warn-callout { background: var(--warn-tint); border-left-color: var(--warn); }

/* ── "trouble signing in?" ───────────────────────────────────────────────── */

/* The sign-in card is narrow because a login form should be. The help beneath
   it is prose, so the column widens only when the help is present - and only on
   a screen with room for it. */
.signin { max-width: 460px; }

.signin-help {
    background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: .2rem .4rem; margin-top: -.4rem;
}
.signin-help > summary {
    cursor: pointer; list-style: none;
    padding: .55rem .7rem; font-size: .88rem; font-weight: 600;
    color: var(--brand); border-radius: var(--radius);
}
.signin-help > summary::-webkit-details-marker { display: none; }
.signin-help > summary::before { content: "\25B8 "; display: inline-block; width: 1em; }
.signin-help[open] > summary::before { content: "\25BE "; }
.signin-help > summary:hover { background: var(--line-soft); }

/* Everything after the summary. Smaller than body text: it is reference, not
   the thing you came to the page to do. */
.signin-help > *:not(summary) { padding: 0 .7rem; font-size: .85rem; }
.signin-help p { margin: 0 0 .7rem; }
.signin-help .callout { font-size: .85rem; margin-left: 0; margin-right: 0; }

/* ── proving an e-mail address ───────────────────────────────────────────── */

.verify {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: .7rem .8rem; background: var(--ground);
}
.verify-head {
    display: flex; align-items: center; gap: .5rem;
    font-weight: 600; font-size: .9rem; margin-bottom: .5rem;
}
.verify-head .spacer { flex: 1; }

/* Six digits read off a phone. Wide-spaced and centred so a transposition is
   visible before the button is pressed. */
.verify-code {
    width: 7rem; letter-spacing: .25em; text-align: center;
    font-family: "Cascadia Mono", Consolas, monospace;
}

/* The password rule, once it has been broken. */
.hint.pwd-bad { color: var(--bad); }

/* ── the product name, and what this tool is ─────────────────────────────── */

/* Two lines: the product large, and the tool it happens to be small underneath.
   Stacked rather than run together because they answer different questions -
   "whose software is this" and "what does this screen do" - and at one size the
   second swallows the first. */
.topbar .brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.15;

    /* min-width:0 is load-bearing. A flex item will not shrink below its
       content width without it, which is the usual reason text-overflow
       silently does nothing. */
    min-width: 0;
    flex-shrink: 1;
}

.topbar .brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar .brand-sub {
    font-size: .72rem;
    font-weight: 500;
    letter-spacing: .04em;
    color: #a8c6db;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The bar also carries the badge, five menus, the operator and a button. When
   room runs short the SUB-CAPTION goes first - it is the line you can most
   afford to lose, and the product name is the one people navigate by. */
@media (max-width: 1180px) {
    .topbar .brand-sub { display: none; }
}
@media (max-width: 720px) {
    .topbar .brand { display: none; }
}

/* On the sign-in card there is nothing competing, so both lines stay and the
   name is allowed to be the largest thing on screen. */
.signin-title {
    font-size: 1.5rem;
    line-height: 1.2;
    margin-bottom: .15rem;
}
.signin-sub {
    font-size: .88rem;
    color: var(--ink-soft);
    margin-bottom: 1.2rem;
}
