/*
 * The whole stylesheet for the web admin. One file, hand written, no framework.
 *
 * NODE IS NOT INSTALLED ON THE BUILD MACHINE - no npm, no vite, no PostCSS - so
 * there is no build step and there is nothing to compile. If you are tempted to
 * add Tailwind, check that `npm` exists first; it does not.
 *
 * Mobile first. The owner opens this on a phone in a noisy restaurant, at arm's
 * length, so the base font is 16px (which also stops iOS zooming a focused
 * input), tap targets are 44px, and the desktop layout is the one @media query
 * at the bottom. Nothing here needs JavaScript: the nav is a checkbox, the
 * expanding bills are <details>, and the trend bars are divs with a width.
 */

:root {
    --ink: #1b1b1b;
    --ink-soft: #6a6a6a;
    --line: #dcdcdc;
    --paper: #f6f6f4;
    --card: #ffffff;
    --accent: #7a1f1f;      /* the brand red off the old POS receipts */
    --good: #1f5d3a;
    --bad: #9a2020;
    --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.centred { display: flex; align-items: center; min-height: 100vh; }

h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }

a { color: var(--accent); }

.muted { color: var(--ink-soft); font-size: .875rem; }
.hint { margin: .25rem 0 0; }
.hint.error, .muted.error { color: var(--bad); }

/* ---------------------------------------------------------------- top bar */

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .6rem .9rem;
    background: var(--ink);
    color: #fff;
}

.brand {
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    margin-right: auto;
}

/* The nav toggle is a checkbox because a phone menu must work with no JS. */
.navtoggle { position: absolute; opacity: 0; pointer-events: none; }

.navtoggle-label {
    display: inline-block;
    padding: .5rem .8rem;
    border: 1px solid #555;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .875rem;
}

.nav { display: none; width: 100%; flex-direction: column; gap: .15rem; }
.navtoggle:checked ~ .nav { display: flex; }

.nav a, .nav button {
    display: block;
    padding: .7rem .4rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid #333;
    font-size: 1rem;
}

.nav .signout { margin: 0; }

.nav .signout button {
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    border-bottom: 1px solid #333;
    color: #f0b8b8;
    cursor: pointer;
    min-height: 44px;
}

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

.page { padding: 1rem .9rem 3rem; max-width: 1100px; margin: 0 auto; width: 100%; }
.page.narrow { max-width: 26rem; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .9rem;
    margin: 0 0 1rem;
}

.notice {
    padding: .7rem .9rem;
    margin: 0 0 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--good);
    background: #eaf5ee;
    color: var(--good);
}

.notice.error {
    border-color: var(--bad);
    background: #fbecec;
    color: var(--bad);
}

ul.notice { padding-left: 2rem; }

/* --------------------------------------------------------------- controls */

button, .button {
    display: inline-block;
    min-height: 44px;
    padding: .55rem 1rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: .95rem;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
}

button:active, .button:active { opacity: .8; }

.button.ghost, .preset {
    background: var(--card);
    color: var(--ink);
    border-color: var(--line);
}

.preset.on { background: var(--ink); color: #fff; border-color: var(--ink); }

input, select, textarea {
    width: 100%;
    min-height: 44px;
    padding: .5rem .6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 1rem;    /* never below 16px: iOS zooms a smaller focused field */
}

textarea { min-height: 5rem; }

input[type="checkbox"] { width: auto; min-height: 0; }

.rowbar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin: 0 0 1rem;
}

.filters { display: flex; flex: 1 1 100%; flex-wrap: wrap; gap: .5rem; }
.filters input, .filters select { flex: 1 1 8rem; }
.filters button { flex: 0 0 auto; }

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

.form .field { margin: 0 0 .9rem; }
.form label { display: block; font-size: .875rem; color: var(--ink-soft); margin: 0 0 .2rem; }
.form .field.bad input, .form .field.bad select, .form .field.bad textarea { border-color: var(--bad); }

.form .check { display: flex; align-items: center; gap: .55rem; font-size: 1rem; color: var(--ink); }
.form .check span { color: var(--ink); }

.card.danger { border-color: var(--bad); display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.card.danger button { background: var(--bad); border-color: var(--bad); }

.cancel-form { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 0; }
.cancel-form input { flex: 1 1 10rem; }

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

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: .55rem .4rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* Cancelled bills and revoked devices stay visible and stay struck through:
   they are still in the records, they are just in no total. */
.cancelled, tr.cancelled td { color: var(--ink-soft); text-decoration: line-through; }

.badge {
    display: inline-block;
    padding: .1rem .4rem;
    border: 1px solid var(--bad);
    border-radius: 4px;
    color: var(--bad);
    font-size: .7rem;
    letter-spacing: .05em;
    text-decoration: none;
}

.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; padding: .5rem 0 1.5rem; }

/* --------------------------------------------------------------- reports */

.period { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.presets { display: flex; gap: .4rem; flex: 1 1 100%; }
.presets .preset { flex: 1 1 0; }
.custom { display: flex; gap: .4rem; flex: 1 1 100%; align-items: flex-end; }
.custom label { flex: 1 1 0; font-size: .8rem; color: var(--ink-soft); }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin: 0 0 1rem; }

.tile {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .7rem;
}

.tile-label { display: block; font-size: .75rem; text-transform: uppercase; color: var(--ink-soft); }
.tile-value { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }

.two-up { display: grid; grid-template-columns: 1fr; gap: 1rem; }

.trend .bar-cell { width: 45%; }
.trend .bar { border-radius: 3px; min-width: 1px; }

.bill { border-bottom: 1px solid var(--line); padding: .35rem 0; }
.bill summary { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; cursor: pointer; padding: .4rem 0; }
.bill-no { font-weight: 600; font-variant-numeric: tabular-nums; }
.amount { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ------------------------------------------------------- pairing code box */

.pairing { border-color: var(--accent); }

.code {
    display: block;
    padding: .6rem;
    margin: .4rem 0;
    background: var(--paper);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8rem;
    word-break: break-all;
}

.code.small { font-size: .7rem; }

/* ------------------------------------------------------------- wider than
   a phone. One query; there is no tablet breakpoint because nothing here
   needs a third layout. */

@media (min-width: 46rem) {
    .navtoggle-label { display: none; }

    .nav {
        display: flex;
        flex-direction: row;
        align-items: center;
        width: auto;
        gap: .2rem;
    }

    .nav a, .nav button { border-bottom: 0; padding: .5rem .6rem; font-size: .9rem; }
    .nav .signout button { width: auto; border-bottom: 0; }

    .page { padding: 1.5rem 1.5rem 4rem; }
    .tiles { grid-template-columns: repeat(4, 1fr); }
    .two-up { grid-template-columns: 1fr 1fr; }
    .filters { flex: 0 1 auto; margin-left: auto; }
    .presets, .custom { flex: 0 1 auto; }
}
