:root {
    color-scheme: light;
    --bg: #e7e9ed;
    --surface: #ffffff;
    --surface-2: #f1f3f5;
    --line: #b7bcc4;
    --text: #17191c;
    --muted: #626a73;
    --nav: #11161a;
    --nav-line: #273036;
    --nav-text: #d9e0e5;
    --nav-muted: #849099;
    --accent: #147a54;
    --accent-light: #7de3b5;
    --danger: #b52f39;
    --font: ui-monospace, SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); font: 13px/1.5 var(--font); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
[data-spinner].is-spinning { cursor: wait !important; opacity: .85; pointer-events: none; }

.app-shell { display: grid; grid-template-columns: 190px minmax(0, 1fr); min-height: 100vh; }
.object-nav {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    padding: 24px 12px 16px;
    border-right: 1px solid var(--nav-line);
    background: var(--nav);
    color: var(--nav-text);
    flex-direction: column;
}
.side-brand { padding: 0 10px 28px; color: var(--nav-text); font-size: 17px; font-weight: 700; text-decoration: none; }
.side-brand span { color: var(--accent-light); animation: cursor-blink 1s step-end infinite; }
@keyframes cursor-blink { 50% { opacity: 0; } }
.object-nav > strong { padding: 0 10px 9px; color: var(--accent-light); font-size: 10px; font-weight: 500; text-transform: uppercase; }
.object-nav nav { display: grid; gap: 3px; }
.object-nav nav a,
.logout-form button {
    display: grid;
    grid-template-columns: 28px 1fr;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    background: transparent;
    color: var(--nav-muted);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.object-nav nav a:hover,
.object-nav nav a.active,
.logout-form button:hover { background: #1d2925; color: var(--accent-light); }
.object-nav nav b,
.logout-form b { font-weight: 400; }
.logout-form { margin: 3px 0 0; }
.object-nav > small { margin-top: auto; padding: 10px; color: var(--nav-muted); overflow-wrap: anywhere; }
.private-status { padding: 10px; border: 1px solid var(--nav-line); color: var(--nav-muted); font-size: 10px; }

.content-shell { display: grid; grid-template-rows: 1fr auto; min-width: 0; min-height: 100vh; }
.page-shell { width: min(1100px, calc(100% - 36px)); margin: 0 auto; padding: 34px 0 70px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.command { margin: 0 0 5px; color: var(--muted); font-size: 11px; }
h1 { margin: 0; font-size: clamp(28px, 5vw, 38px); line-height: 1; letter-spacing: -.05em; }
.button { padding: 8px 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: 2px 2px 0 #c5c8ce; text-decoration: none; }
.button.primary { border-color: var(--accent); background: var(--accent); color: white; box-shadow: 2px 2px 0 #0c4932; }

.panel { border: 1px solid var(--line); background: var(--surface); box-shadow: 2px 2px 0 #c5c8ce; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; min-height: 42px; padding: 0 13px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.panel-head h2 { margin: 0; font-size: 12px; font-weight: 600; }
.panel-head span { color: var(--muted); font-size: 10px; }
.site-footer { display: flex; justify-content: space-between; min-height: 35px; padding: 9px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.site-footer span:last-child::before { content: "●"; margin-right: 7px; color: var(--accent); }
.gate-page .site-footer span:last-child::before { color: var(--danger); }

/* dashboard */
.information-panel { margin-bottom: 16px; border: 1px solid var(--line); background: #f7faf8; box-shadow: 2px 2px 0 #c5c8ce; }
.information-panel header { display: flex; align-items: center; justify-content: space-between; min-height: 38px; padding: 0 13px; border-bottom: 1px solid var(--line); background: #e6f0eb; }
.information-panel h2 { margin: 0; color: var(--accent); font-size: 12px; }
.information-panel header span { color: var(--muted); font-size: 10px; }
.information-panel > div { padding: 13px; }
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 16px; align-items: start; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid #d8dbe1; border-right: 1px solid #d8dbe1; text-align: left; white-space: nowrap; }
th:last-child, td:last-child { border-right: 0; }
th { background: #e7e9ed; color: var(--text); font-size: 10px; font-weight: 500; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #eff7f3; }
td code { color: var(--muted); }
td code.ok { color: var(--accent); }
td code.bad { color: var(--danger); }
td:last-child { text-align: right; }
td a { color: var(--accent); font-size: 17px; text-decoration: none; }
.empty-state { margin: 0; padding: 26px 13px; color: var(--muted); }
.dashboard-side { display: grid; gap: 12px; }
.status-panel dl { margin: 0; }
.status-panel dl div { display: flex; align-items: center; justify-content: space-between; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.status-panel dl div:last-child { border-bottom: 0; }
.status-panel dt { color: var(--muted); }
.status-panel dd { margin: 0; }

/* register */
.form-layout { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 16px; align-items: start; }
.form-index { position: sticky; top: 16px; display: grid; border: 1px solid var(--line); background: var(--surface); box-shadow: 2px 2px 0 #c5c8ce; }
.form-index a { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); text-decoration: none; }
.form-index a:hover { background: var(--surface-2); color: var(--accent); }
.form-index span { padding: 12px; color: var(--muted); font-size: 10px; }
.receipt-form > section { padding: 20px; border-bottom: 1px solid var(--line); }
.form-head { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; margin-bottom: 18px; }
.form-head b,
.form-head span { color: var(--muted); font-size: 10px; font-weight: 400; }
.form-head h2 { margin: 0; font-size: 13px; }
.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
label { display: grid; gap: 6px; }
label > span { color: var(--muted); font-size: 10px; }
label.wide { grid-column: span 3; }
label small,
.form-errors { color: var(--danger); }
.form-errors { padding: 12px 20px; border-bottom: 1px solid var(--danger); background: #fff2f2; }
.form-errors ul { margin: 0; padding-left: 20px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 0; outline: 0; background: #f7f8f9; color: var(--text); }
input, select { height: 36px; padding: 0 9px; }
textarea { padding: 9px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: inset 3px 0 var(--accent); }
.form-actions { display: flex; justify-content: flex-end; padding: 14px 20px; }
.form-actions button { padding: 8px 22px; border: 1px solid var(--accent); background: var(--accent); color: white; cursor: pointer; }
.form-actions button:hover { background: #0f6243; }
.form-actions button:disabled { background: #0f6243; cursor: wait; opacity: .85; }

/* detail */
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 16px; align-items: start; }
.detail-list { margin: 0; }
.detail-list div { display: grid; grid-template-columns: 180px 1fr; min-height: 42px; border-bottom: 1px solid var(--line); }
.detail-list div:last-child { border-bottom: 0; }
.detail-list dt,
.detail-list dd { padding: 11px 13px; }
.detail-list dt { color: var(--muted); border-right: 1px solid var(--line); background: #f3f4f6; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.detail-side { display: grid; gap: 12px; }
.detail-side form { margin: 0; }
.delete-button { width: 100%; padding: 10px; border: 1px solid var(--danger); background: transparent; color: var(--danger); cursor: pointer; }
.delete-button:hover { background: var(--danger); color: white; }

/* access */
.gate-page .page-shell { display: grid; min-height: calc(100vh - 35px); place-items: center; }
.gate { display: grid; grid-template-columns: 150px minmax(320px, 500px); width: min(680px, 100%); border: 1px solid var(--line); background: var(--surface); box-shadow: 8px 8px 0 #c6c9cf; }
.gate-code { display: grid; place-items: center; min-height: 280px; border-right: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 54px; font-weight: 700; }
.gate.invalid .gate-code { color: var(--danger); }
.gate-body { padding: 42px; }
.gate-body h1 { margin-bottom: 14px; }
.gate-body > p:not(.command) { color: var(--muted); }
.gate-body dl { margin: 28px 0 0; border-top: 1px solid var(--line); }
.gate-body dl div { display: grid; grid-template-columns: 90px 1fr; padding: 9px 0; border-bottom: 1px solid var(--line); }
.gate-body dt { color: var(--muted); }
.gate-body dd { margin: 0; }

@media (max-width: 800px) {
    .app-shell { display: block; }
    .object-nav { position: static; height: auto; padding: 14px 12px; border-right: 0; border-bottom: 1px solid var(--nav-line); }
    .side-brand { padding: 0 8px 12px; }
    .object-nav > strong { display: none; }
    .object-nav nav { display: flex; overflow-x: auto; }
    .object-nav nav a,
    .logout-form button { min-width: max-content; }
    .logout-form { position: absolute; top: 42px; right: 12px; }
    .logout-form button { width: auto; }
    .logout-form span { display: none; }
    .object-nav > small { display: none; }
    .private-status { position: absolute; top: 12px; right: 12px; border: 0; }
    .page-shell { width: calc(100% - 24px); padding-top: 22px; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .dashboard-layout,
    .form-layout,
    .detail-layout { grid-template-columns: 1fr; }
    .dashboard-side,
    .detail-side { grid-row: 1; grid-template-columns: 1fr 1fr; }
    .form-index { position: static; grid-template-columns: 1fr 1fr; }
    .form-index span { display: none; }
    .field-grid { grid-template-columns: 1fr; }
    label.wide { grid-column: auto; }
    .detail-list div { grid-template-columns: 120px 1fr; }
    .gate-page .page-shell { min-height: calc(100vh - 100px); }
    .gate { grid-template-columns: 1fr; }
    .gate-code { min-height: 110px; border-right: 0; border-bottom: 1px solid var(--line); }
    .gate-body { padding: 28px; }
}

@media (prefers-reduced-motion: reduce) {
    .side-brand span { animation: none; }
}
