/* What every staff app shares (Plan 17 Phase D): the Preset #1 tokens, the base, the
   controls, the account pages and the top bar. Each app adds its own after this. */
:root {
    --ink: #20251F;
    --ink-soft: #333830;
    --sidebar: #232722;
    --ground: #F1F3EE;
    --surface: #FFFFFF;
    --line: #E2E6DD;
    --line-soft: #ECEFE8;
    --muted: #6A7265;
    --andaman: #1E5A4E;
    --andaman-dark: #143E36;
    --celadon: #DCE5DC;
    --garuda: #B23A2B;
    --amber: #B4530A;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: 'Anuphan', 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
}

h1, h2, h3 { font-family: 'Bai Jamjuree', 'Segoe UI', system-ui, sans-serif; margin: 0; }
a { color: var(--andaman); text-decoration: none; }
a:hover { color: var(--andaman-dark); }

/* Panels & tables */
.panel { background: var(--surface); border: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; }
.panel-head h2 { font-size: 16px; font-weight: 600; }

table { border-collapse: collapse; width: 100%; }
th {
    font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
    color: var(--muted); text-align: left; padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}
td { font-size: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); }
tbody tr:hover { background: #FAFBF8; }

/* Chips */
.chip { display: inline-flex; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.chip-green { background: var(--celadon); color: var(--andaman); }
.chip-grey { background: var(--line-soft); color: var(--muted); }
.chip-red { background: #F6E4E1; color: var(--garuda); }
.chip-amber { background: #F7E9DA; color: var(--amber); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 16px;
    border: none; cursor: pointer;
    font: inherit; font-size: 13px; font-weight: 600;
}
.btn-primary { background: var(--andaman); color: #FFF; }
.btn-primary:hover { background: var(--andaman-dark); }
.btn-ghost { background: transparent; border: 1px solid var(--ink); color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: #FFF; }
.btn-danger { background: transparent; border: 1px solid var(--garuda); color: var(--garuda); }
.btn-danger:hover { background: var(--garuda); color: #FFF; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
.field label {
    font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
    color: var(--muted);
}
.field input[type=text], .field input[type=number], .field select, .field textarea {
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    font: inherit; font-size: 14px;
    color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--andaman); outline-offset: -1px;
}
.field textarea { min-height: 110px; resize: vertical; }
.field-hint { font-size: 12px; color: var(--muted); }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.section-title {
    font-family: 'Bai Jamjuree', sans-serif; font-size: 15px; font-weight: 600;
    grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--line-soft);
}
.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 8px; }

/* Sign-in */
.plain { flex-grow: 1; }
.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.signin-card {
    width: 100%; max-width: 380px;
    background: var(--surface); border: 1px solid var(--line);
    padding: 32px;
    display: flex; flex-direction: column; gap: 18px;
}
.signin-brand { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.signin-brand .brand-name { color: var(--ink); }
.signin-brand .brand-sub { color: var(--muted); }
.signin-card form { display: flex; flex-direction: column; gap: 18px; }
.signin-card .field input {
    padding: 10px 12px; background: var(--surface); border: 1px solid var(--line);
    font: inherit; font-size: 14px; color: var(--ink); width: 100%;
}
.signin-error { background: #F6E4E1; color: var(--garuda); padding: 10px 12px; font-size: 13px; }

/* Setting up an authenticator. The QR code keeps a white quiet zone round it
   whatever the theme, or phone cameras stop reading it. */
.authenticator-qr { display: flex; justify-content: center; }
.authenticator-qr svg { width: 100%; max-width: 220px; height: auto; background: #FFF; }
.setup-key {
    display: block; margin-top: 6px; padding: 8px 10px;
    background: var(--line-soft); color: var(--ink);
    font-size: 14px; letter-spacing: 0.04em; word-break: break-all;
}
.recovery-codes {
    margin: 0; padding: 12px 12px 12px 36px;
    background: var(--line-soft);
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 18px;
}
.recovery-codes code { font-size: 14px; color: var(--ink); }
@media (max-width: 360px) { .recovery-codes { grid-template-columns: 1fr; } }
.field-error { color: var(--garuda); font-size: 12px; }

/* ---------- The top bar over every staff app (Plan 17 §2.11) ---------- */
.staff-bar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 14px;
    min-height: 44px; padding: 0 16px;
    background: var(--ink); color: #FFF;
    font-size: 13px;
}
.staff-home { display: inline-flex; align-items: center; gap: 10px; color: #FFF; margin-right: auto; }
.staff-home:hover { color: #FFF; }
.staff-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; background: var(--andaman);
    font-family: 'Bai Jamjuree', sans-serif; font-weight: 700; font-size: 11px; letter-spacing: .04em;
}
.staff-here { font-family: 'Bai Jamjuree', sans-serif; font-weight: 600; font-size: 14px; }
.staff-switch { position: relative; }
.staff-switch summary {
    list-style: none; cursor: pointer; padding: 6px 12px;
    border: 1px solid #3D423B; color: #C6CDC1; font-weight: 600;
}
.staff-switch summary::-webkit-details-marker { display: none; }
.staff-switch[open] summary { background: var(--ink-soft); color: #FFF; }
.staff-switch nav {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.staff-switch nav a { padding: 10px 14px; color: var(--ink); border-bottom: 1px solid var(--line-soft); }
.staff-switch nav a:last-child { border-bottom: 0; }
.staff-switch nav a:hover { background: var(--ground); }
.staff-switch nav a[aria-current=page] { font-weight: 600; box-shadow: inset 3px 0 0 var(--andaman); }
.staff-who { display: flex; flex-direction: column; line-height: 1.2; color: #FFF; font-weight: 600; }
.staff-who small { color: #A9B0A5; font-weight: 400; font-size: 11px; }
.staff-out { color: #C6CDC1; border: 1px solid #3D423B; padding: 6px 12px; font-weight: 600; }
.staff-out:hover { background: var(--ink-soft); color: #FFF; }
@media (max-width: 520px) { .staff-who { display: none; } }
