/* AppSync admin — Light Mandalas brand (Brand Manual, 28 Sept 2026)
   Graphite backgrounds · gold headings · warm light text · Rubik throughout.
   Deep Wine is a small accent only (≤ 5%). Blue / Emerald are optional status accents. */
:root {
    color-scheme: dark;
    /* Brand palette */
    --signature-gold: #C79A3C;
    --crown-gold: #E0B85A;
    --light-beam: #F7E8C7;
    --graphite: #11100F;
    --deep-wine: #291314;
    --temple-brown: #2B1D17;
    --pearl: #F8F2E8;
    --ash: #A7A09A;
    --frequency-blue: #1B4367;
    --emerald: #1A5B4C;

    /* UI roles (derived from the palette) */
    --bg: var(--graphite);
    --panel: #181614;          /* graphite, one step lighter */
    --panel-2: #1F1C19;        /* hover / table head */
    --field: #0C0B0A;          /* inputs */
    --ink: var(--pearl);
    --muted: var(--ash);
    --line: rgba(199, 154, 60, 0.22);   /* gold hairline, as in the manual */
    --line-soft: rgba(248, 242, 232, 0.08);
    --heading: var(--crown-gold);
    --accent: var(--signature-gold);
    --radius: 10px;

    --ok-bg: rgba(26, 91, 76, 0.35);     --ok-ink: #8FD3BE;
    --info-bg: rgba(27, 67, 103, 0.45);  --info-ink: #A9C8E6;
    --warn-bg: rgba(199, 154, 60, 0.16); --warn-ink: var(--crown-gold);
    --bad-bg: rgba(122, 38, 40, 0.38);   --bad-ink: #F0B3AC;
    --mute-bg: rgba(167, 160, 154, 0.12);--mute-ink: var(--ash);
    --danger: #9E3434;
}

* { box-sizing: border-box; }
html {
    font-family: "Rubik", "Noto Sans Thai", -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--crown-gold); text-decoration: none; }
a:hover { color: var(--light-beam); text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; color: var(--light-beam); }
h1, h2, h3 { margin: 0; line-height: 1.2; color: var(--heading); font-weight: 700; }
h1 { font-size: 28px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 12px; margin: 22px 0 8px; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-weight: 500; }
strong { color: var(--pearl); font-weight: 500; }
::selection { background: rgba(224, 184, 90, .35); }
.muted { color: var(--muted); }
.warn-text { color: var(--crown-gold); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.lead { color: var(--muted); margin: 0 0 18px; max-width: 860px; font-size: 15px; }
.hint { color: var(--muted); font-size: 12px; margin: -4px 0 0; }

/* layout */
.app-shell { display: flex; min-height: 100vh; position: relative; }
.app-shell::after {           /* Deep Wine corner accent, as on the manual pages (~2% of the screen) */
    content: ""; position: fixed; right: 0; bottom: 0; width: 220px; height: 220px; pointer-events: none; z-index: 0;
    background: linear-gradient(135deg, transparent 50%, var(--deep-wine) 50%); opacity: .9;
}
.sidebar {
    width: 252px; flex: 0 0 252px; background: #0B0A09; color: var(--pearl); display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line); z-index: 2;
}
.sidebar-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px 16px 18px; border-bottom: 1px solid var(--line); }
.sidebar-brand img { width: 124px; height: auto; display: block; }
.sidebar-brand strong { display: block; font-size: 15px; color: var(--crown-gold); font-weight: 700; letter-spacing: .06em; }
.sidebar-brand small { color: var(--ash); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section { padding: 16px 10px 6px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.nav-link { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--pearl); border-left: 2px solid transparent; }
.nav-link:hover { background: rgba(199, 154, 60, .08); color: var(--light-beam); text-decoration: none; }
.nav-link.active { background: var(--temple-brown); color: var(--crown-gold); border-left-color: var(--signature-gold); font-weight: 500; }
.nav-icon { width: 16px; text-align: center; color: var(--accent); opacity: .9; }
.sidebar-foot { padding: 12px 16px; font-size: 11px; color: var(--ash); border-top: 1px solid var(--line); }
.main { flex: 1; min-width: 0; padding: 28px 32px 56px; position: relative; z-index: 1; }
.page-head { margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.page-head::before { content: "Light Mandalas · AppSync"; display: block; color: var(--accent); font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8px; }
.mobile-bar { display: none; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
details.panel > summary { cursor: pointer; list-style: none; color: var(--crown-gold); }
details.panel > summary strong { color: var(--crown-gold); }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel[open] > summary { margin-bottom: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; align-items: start; }
.cols > .panel { margin-bottom: 0; }
.cols + .panel, .cols + section, .cols + .cols { margin-top: 18px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line-soft); border-top: 2px solid var(--signature-gold); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi strong { font-size: 28px; font-weight: 700; color: var(--pearl); font-variant-numeric: tabular-nums; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { font-size: 11px; color: var(--accent); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; background: transparent; border-bottom: 1px solid var(--line); }
tbody tr:hover td { background: rgba(199, 154, 60, .04); }
table.compact th, table.compact td { padding: 7px 8px; font-size: 13px; }
tr.dim td { opacity: .5; }
tr.highlight td { background: rgba(224, 184, 90, .10); }
code.code { font-size: 14px; font-weight: 700; letter-spacing: .06em; color: var(--crown-gold); }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.bad { background: var(--bad-bg); color: var(--bad-ink); }
.badge.info { background: var(--info-bg); color: var(--info-ink); }
.badge.mute { background: var(--mute-bg); color: var(--mute-ink); }

/* forms */
input, select, textarea, button { font: inherit; }
input, select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid rgba(248, 242, 232, .14); border-radius: 8px;
    background: var(--field); color: var(--pearl);
}
input::placeholder, textarea::placeholder { color: #6E6862; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(224, 184, 90, .30); border-color: var(--signature-gold); }
select option { background: var(--panel); color: var(--pearl); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--signature-gold); }
input[type=date] { color-scheme: dark; }
input.ver { width: 100px; font-family: ui-monospace, Menlo, monospace; }
input.short { width: 90px; display: inline-block; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; color: var(--pearl); }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; flex-wrap: wrap; }
label.check input[type=date] { width: auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.narrow { max-width: 400px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; align-items: start; }
.grid-form .span2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.grid-form .form-actions { grid-column: 1 / -1; }
fieldset.expiry { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
fieldset.expiry legend { font-weight: 500; font-size: 12px; padding: 0 6px; color: var(--accent); letter-spacing: .06em; text-transform: uppercase; }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type=search] { max-width: 320px; }
.filters select { width: auto; }
form.inline { display: inline; }

/* buttons — gold on graphite */
.btn, button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; border-radius: 8px;
    border: 1px solid rgba(199, 154, 60, .45); background: transparent; color: var(--crown-gold); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover, button:hover { text-decoration: none; background: rgba(199, 154, 60, .12); color: var(--light-beam); border-color: var(--crown-gold); }
.btn.primary { background: var(--signature-gold); border-color: var(--signature-gold); color: var(--graphite); font-weight: 700; }
.btn.primary:hover { background: var(--crown-gold); border-color: var(--crown-gold); color: var(--graphite); }
.btn.warn { background: rgba(199, 154, 60, .16); border-color: rgba(224, 184, 90, .5); color: var(--crown-gold); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--pearl); }
.btn.danger:hover { background: #B43E3E; color: var(--pearl); }
.btn.danger-outline { color: var(--bad-ink); border-color: rgba(240, 179, 172, .4); }
.btn.danger-outline:hover { background: var(--bad-bg); color: var(--pearl); }
.btn.small { padding: 5px 11px; font-size: 12px; }
.icon-button { cursor: pointer; font-size: 20px; padding: 4px 10px; color: var(--crown-gold); }
.pager { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }

/* notices */
.notice { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; border-left: 3px solid; }
.notice.success { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--emerald); }
.notice.error { background: var(--bad-bg); color: var(--bad-ink); border-color: #7A2628; }

/* code detail */
.code-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; border-top: 2px solid var(--signature-gold); }
.hero-code { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-code code { font-size: 30px; font-weight: 700; letter-spacing: .1em; color: var(--crown-gold); font-family: "Rubik", sans-serif; }
.hero-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.copy { cursor: copy; }
.copy.copied::after { content: " ✓ copied"; color: var(--ok-ink); font-size: 12px; font-family: "Rubik", sans-serif; }
.new-codes { border-color: rgba(224, 184, 90, .5); background: linear-gradient(180deg, rgba(199, 154, 60, .10), rgba(199, 154, 60, .03)); }
.code-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.chip { background: var(--field); border: 1px solid rgba(224, 184, 90, .5); color: var(--crown-gold); padding: 6px 12px; border-radius: 6px; font-weight: 700; letter-spacing: .08em; font-size: 15px; }
.doc pre, pre.mini { background: var(--field); color: var(--light-beam); border: 1px solid var(--line-soft); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12px; }
pre.mini { white-space: pre-wrap; max-height: 420px; overflow: auto; }
.doc li { margin: 4px 0; }
.mono-area { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; }
.small-print { font-size: 12px; line-height: 1.6; }
details > summary { cursor: pointer; }

/* activation card */
.card-controls { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.card-preview { display: block; width: 100%; max-width: 640px; height: auto; aspect-ratio: 1484 / 1060; border-radius: 8px; background: #0B0A09; border: 1px solid var(--line); }
.edit-panel form { max-width: 760px; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--graphite); position: relative; overflow: hidden; }
.login-body::after { content: ""; position: fixed; right: 0; bottom: 0; width: 260px; height: 260px; background: linear-gradient(135deg, transparent 50%, var(--deep-wine) 50%); }
.login-card { width: min(400px, calc(100% - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 34px 30px; text-align: center; position: relative; z-index: 1; }
.login-card .stack { text-align: left; margin-top: 20px; }
.login-logo { width: 112px; height: auto; margin-bottom: 10px; }
.login-card h1 { font-size: 30px; }
.login-card .btn.primary { width: 100%; padding: 11px; }

[hidden] { display: none !important; }

/* mobile */
@media (max-width: 900px) {
    .sidebar { position: fixed; z-index: 20; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
    .nav-toggle:checked + .app-shell .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .55); }
    .mobile-bar { display: flex; align-items: center; gap: 10px; margin: -8px 0 14px; color: var(--crown-gold); }
    .main { padding: 18px 16px 40px; }
    .cols { grid-template-columns: 1fr; }
    .row2, .row3, .code-hero { grid-template-columns: 1fr; }
    .grid-form .span2 { grid-column: auto; }
    .app-shell::after { width: 120px; height: 120px; }
}

/* ---- AppSync 2.3: session log, pause reasons, installments ---- */
.panel.filters { display: block; }
.row-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row-filters label { flex: 1 1 150px; margin: 0; }
.row-filters .form-actions { margin: 0; flex: 0 0 auto; }
.hold-banner { width: 100%; padding: 10px 14px; border-radius: var(--radius); background: var(--bad-bg); color: var(--bad-ink); margin-bottom: 8px; }
.hold-banner .muted { color: var(--ash); }
.hold-form { width: 100%; }
.hold-form > summary { list-style: none; display: inline-block; }
.hold-form > summary::-webkit-details-marker { display: none; }
.hold-form[open] > form { margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
details.panel > summary .badge { margin-left: 8px; }
