/* MEG Platform sign-in and staff pages. Tokens follow the "MEG Platform Redesign" canvas. */
:root {
    --ground: #F6F5F2;
    --surface: #FFFFFF;
    --line: #E6E3DC;
    --line-strong: #DAD6CD;
    --text: #1C1B19;
    --text-2: #4A4740;
    --muted: #6B675F;
    --danger: #B3261E;
    --danger-tint: #FBE9E7;
    --ok: #1C7347;
    --shop-accent: #1C1B19;
    --shop-tint: #F1EFEA;
    --shop-ink: #1C1B19;
    --radius: 10px;
    --font: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    background: var(--ground);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

.shop-strip {
    height: 4px;
    background: var(--shop-accent);
    transition: background-color 160ms ease;
}

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
    outline: 2px solid var(--shop-accent);
    outline-offset: 2px;
}

/* ---------- Sign-in ---------- */

.auth {
    width: min(440px, 100% - 32px);
    margin: 0 auto;
    padding: 48px 0 64px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand__tile {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--shop-accent);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.04em;
    transition: background-color 160ms ease;
}

.brand__text { display: flex; flex-direction: column; }
.brand__name { font-weight: 600; }
.brand__place { font-size: 13px; color: var(--shop-ink); }

.panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.panel h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.panel p.lead { margin: -8px 0 0; color: var(--text-2); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; color: var(--muted); }
.field__hint { font-size: 12px; color: var(--muted); }

.input {
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
}

.input:focus { border-color: var(--text); outline: none; }

.input--pin { font-family: var(--mono); letter-spacing: 0.4em; }
.input--pin::placeholder { font-family: var(--font); letter-spacing: normal; }

input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--text); }

.segmented {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 4px;
    margin: 0;
    border: 0;
    border-radius: 12px;
    background: rgba(28, 27, 25, 0.07);
}

.shop-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.shop-field legend { padding: 0 0 6px; }

.segmented label { position: relative; }

.segmented input {
    position: absolute;
    opacity: 0;
    inset: 0;
}

.segmented span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    border-radius: 9px;
    color: var(--muted);
    cursor: pointer;
}

.segmented input:checked + span {
    background: var(--surface);
    color: var(--shop-ink);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(28, 27, 25, 0.14);
}

.segmented input:focus-visible + span { outline: 2px solid var(--shop-accent); outline-offset: 1px; }

.button {
    height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--radius);
    background: var(--text);
    color: #FFFFFF;
    font-weight: 600;
}

.button:disabled { opacity: 0.55; cursor: progress; }

.button--quiet {
    height: auto;
    padding: 6px 0;
    background: transparent;
    color: var(--text-2);
    font-weight: 500;
    text-align: left;
}

.button--quiet:hover { color: var(--text); text-decoration: underline; }

.error {
    margin: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--danger-tint);
    color: var(--danger);
    font-size: 14px;
}

.error:empty { display: none; }

/* People grid: tap your name */
.people {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.person {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: 112px;
    padding: 16px 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.person:hover { border-color: var(--text); }

.person__initials {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--shop-tint);
    color: var(--shop-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.person__name { font-weight: 500; }

/* No double-tap zoom (Pourya, 2026-11-03: typing a PIN quickly zoomed the screen in instead of
   taking the key; DECISIONS (395)). The app has had this since 2026-10-18 (admin.css); the sign-in
   pages have their own stylesheet and never got it. manipulation keeps scrolling and two-finger
   pinch zoom, and drops the short wait before a tap registers. On every element: Safari reads it
   from the element touched. */
*,
*::before,
*::after {
    touch-action: manipulation;
}

/* PIN pad */
.pin-dots {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 6px 0;
}

.pin-dots span {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--text);
}

.pin-dots span.is-filled { background: var(--text); }

.pin-dots.is-wrong { animation: shake 280ms ease; }

@keyframes shake {
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.key {
    height: 60px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    font-family: var(--mono);
    font-size: 22px;
}

.key:active { background: var(--shop-tint); }
.key--plain { border-color: transparent; background: transparent; font-family: var(--font); font-size: 15px; color: var(--text-2); }

@media (prefers-reduced-motion: reduce) {
    .pin-dots.is-wrong { animation: none; }
    .shop-strip, .brand__tile { transition: none; }
}

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

.page {
    width: min(1040px, 100% - 32px);
    margin: 0 auto;
    padding: 28px 0 64px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.page__head {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.page__head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.page__head .spacer { flex-grow: 1; }

.link { color: var(--text-2); }
.link:hover { color: var(--text); }

.who { color: var(--muted); font-size: 14px; }

.button--small {
    height: 36px;
    padding: 0 12px;
    font-size: 14px;
}

.button--outline {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line-strong);
    font-weight: 500;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.staff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.staff-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 400;
    font-size: 13px;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}

.staff-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #EEECE6;
    vertical-align: middle;
}

.staff-table tr:last-child td { border-bottom: 0; }
.staff-table tr.is-inactive td { color: var(--muted); }

.staff-name { display: flex; flex-direction: column; }
.staff-name strong { font-weight: 600; }
.staff-name span { font-size: 13px; color: var(--muted); }
.staff-name .staff-works-at { color: #7A4F00; font-weight: 600; }

/* Works at (DECISIONS (327)): a tick per location. */
.works-at { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; min-width: 0; }
.works-at__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.add-form .works-at { grid-column: 1 / -1; }
.inline-form--fields { flex-wrap: wrap; }
.inline-form .works-at { flex: none; flex-wrap: nowrap; }
.works-at__label, .works-at__option { white-space: nowrap; }
.works-at__option { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 14px; cursor: pointer; }
.works-at__option input { width: 18px; height: 18px; }

.select {
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
}

/* Drop-downs: the browser's arrow sat against the right edge; our own chevron, with room around it. */
select.select,
select.input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px;
    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='%236b6760' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
    cursor: pointer;
}

select.select { padding-left: 12px; }

.tag { font-size: 12px; font-weight: 500; }
.tag--ok { color: var(--ok); }
.tag--missing { color: var(--danger); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 16px 14px;
    background: #FAF9F6;
    border-bottom: 1px solid #EEECE6;
}

.inline-form .input { height: 38px; flex-grow: 1; max-width: 260px; }

.add-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    padding: 20px;
    align-items: end;
}

.add-form h2 { grid-column: 1 / -1; margin: 0; font-size: 16px; font-weight: 600; }
.add-form .error, .add-form .notice { grid-column: 1 / -1; }

.notice {
    margin: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #EAF3EE;
    color: #1C5E3B;
    font-size: 14px;
}

.notice:empty { display: none; }

@media (max-width: 760px) {
    /* A person as a card (DECISIONS (230)): name and "Can sign in" on top, the role, then the PIN
       and last sign-in as one quiet line each, then the buttons. */
    .staff-table, .staff-table tbody { display: block; }
    .staff-table thead { display: none; }
    .staff-table tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "name active" "role role" "pin pin" "when when" "actions actions";
        gap: 8px 12px;
        padding: 16px;
        border-bottom: 1px solid #EEECE6;
    }
    .staff-table td { padding: 0; border: 0; }
    .staff-table td:first-child { grid-area: name; }
    .staff-table .cell-role { grid-area: role; }
    .staff-table .cell-role .select { width: 100%; height: 44px; }
    .staff-table .cell-pin { grid-area: pin; }
    .staff-table .cell-when { grid-area: when; }
    .staff-table .cell-active { grid-area: active; align-self: start; }
    .staff-table .cell-actions { grid-area: actions; padding-top: 4px; }
    .staff-table .cell-actions .row-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .staff-table .cell-actions .button { min-height: 44px; }
    /* The column names are hidden on a phone, so each value says what it is. */
    .staff-table td[data-label] { display: flex; align-items: center; gap: 8px; font-size: 14px; }
    .staff-table td[data-label]::before { content: attr(data-label); color: var(--muted); }
    .staff-table .tag { font-size: 14px; }
    .page__head .who { display: none; }
    .page__head { gap: 10px 14px; }
    .staff-table tr.inline-form-row { display: block; }
    .staff-table tr.inline-form-row td { display: block; }
    .inline-form { display: grid; grid-template-columns: 1fr auto auto; padding: 12px 16px 16px; }
    .inline-form > :first-child { grid-column: 1 / -1; }
    .inline-form .input { min-width: 0; max-width: none; height: 44px; }
    .staff-table tr.inline-form-row { padding: 0; }
    .inline-form .button { min-height: 44px; }
    /* Edit's name and email: each field its own row, then Save and Cancel side by side. */
    .inline-form--fields { grid-template-columns: 1fr 1fr; }
    .inline-form--fields .input { grid-column: 1 / -1; }
    .inline-form .works-at { grid-column: 1 / -1; flex-wrap: wrap; }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 14px;
    color: var(--text-2);
    cursor: pointer;
}

.check input { margin: 2px 0 0; flex-shrink: 0; }
.check__note { color: var(--muted); }
.two-factor-setting { padding: 14px 16px; }
.two-factor-setting .check__note { display: block; margin-top: 2px; font-size: 13px; }

.counters {
    display: flex;
    flex-direction: column;
}

.counter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #EEECE6;
    font-size: 14px;
}

.counter-row:last-child { border-bottom: 0; }
.counter-row span { color: var(--muted); font-size: 13px; }
.section-title { margin: 0; padding: 14px 16px; font-size: 16px; font-weight: 600; border-bottom: 1px solid var(--line); }

/* Staff: what each role can do (staff.html, DECISIONS (88)). */
.roles-head .section-title { border-bottom: 0; padding-bottom: 2px; }
.roles-note { margin: 0; padding: 0 16px 12px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
.roles-scroll { overflow-x: auto; }
.roles-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.roles-table th, .roles-table td { padding: 10px 16px; border-bottom: 1px solid var(--line); text-align: center; }
.roles-table thead th { font-weight: 500; color: var(--muted); white-space: nowrap; }
.roles-table tbody th { text-align: left; font-weight: 400; }
.roles-table tr:last-child th, .roles-table tr:last-child td { border-bottom: 0; }
.roles-table input:disabled { opacity: 0.55; cursor: default; }
@media (max-width: 760px) {
    /* The tick columns as narrow as their words, so what each row means gets the room. */
    .roles-table th, .roles-table td { padding: 10px 6px; }
    .roles-table tbody th { padding-left: 16px; }
    .roles-table thead th, .roles-table td { width: 1%; }
    .roles-table thead th { white-space: normal; font-size: 13px; line-height: 1.2; }
    .roles-table thead th:first-child { width: auto; }
}

/* Hirbo's mark (DECISIONS (342)): the tile before a location is known, and a small "Hirbo" under
   the sign-in. */
.brand__tile--mark { background: none; padding: 0; }
.brand__tile--mark img, .brand__mark { width: 40px; height: 40px; display: block; }
.auth__by {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 28px;
    color: var(--muted, #6B675F);
    font-size: 13px;
    font-weight: 600;
}
.auth__by img { border-radius: 4px; }
.auth__by[hidden] { display: none; }

/* Two-step sign-in (login.js, DECISIONS (367)). */
.input--code {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 22px;
    letter-spacing: 0.2em;
    text-align: center;
}

.steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding-left: 20px;
    font-size: 15px;
    color: var(--text-2);
    line-height: 1.45;
}

.qr {
    width: 176px;
    height: 176px;
    margin: 10px 0 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #FFFFFF;
}

.qr svg {
    display: block;
    width: 100%;
    height: 100%;
}

.setup-key {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 13px;
    color: var(--text);
    word-break: break-all;
}

.backup-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 20px;
    margin: 0;
    padding: 14px 18px 14px 36px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2, #FBFAF8);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 16px;
}

.backup-actions {
    display: flex;
    gap: 10px;
}

.button--secondary {
    height: 40px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
}
