:root {
  color-scheme: dark;
  --ink: #0b080a;
  --surface: #151014;
  --surface-2: #1e151b;
  --wine: #6b173d;
  --wine-bright: #a62a61;
  --gold: #d9b66f;
  --gold-soft: #f0ddb2;
  --text: #f8f1eb;
  --muted: #b9a9ae;
  --line: rgba(217, 182, 111, 0.22);
  --success: #55c28b;
  --danger: #e55b6d;
  --warning: #e0a84b;
  --radius: 18px;
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--ink); overflow-x: hidden; }
body { margin: 0; min-width: 320px; color: var(--text); background: radial-gradient(circle at 90% 0, rgba(107,23,61,.26), transparent 34rem), radial-gradient(circle at 5% 40%, rgba(217,182,111,.08), transparent 28rem), var(--ink); min-height: 100vh; overflow-x: hidden; }
a { color: var(--gold-soft); }
button, input, select, textarea { font: inherit; }
button, .button-link { min-height: 46px; border-radius: 12px; padding: .7rem 1rem; cursor: pointer; font-weight: 700; transition: transform .16s ease, opacity .16s ease, border-color .16s ease; }
button:hover, .button-link:hover { transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: wait; transform: none; }
.primary { color: #160e08; background: linear-gradient(135deg, #f0d28e, #b98b3e); border: 1px solid #f6dea4; box-shadow: 0 8px 30px rgba(197,147,65,.12); }
.secondary { color: white; background: linear-gradient(135deg, #8c2351, #54142f); border: 1px solid #b74576; }
.ghost { color: var(--gold-soft); background: transparent; border: 1px solid var(--line); }
.danger { color: #ffecef; background: #571a28; border: 1px solid #a83b50; }
.small { min-height: 46px; padding: .45rem .75rem; font-size: .82rem; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; min-height: 74px; padding: .65rem max(1rem, calc((100vw - 1180px)/2)); background: rgba(11,8,10,.89); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--text); text-decoration: none; margin-right: auto; }
.brand-orb, .brand-mark { display: grid; place-items: center; border: 1px solid var(--gold); color: var(--gold); border-radius: 50%; background: radial-gradient(circle at 35% 25%, #402933, #130d11 70%); box-shadow: inset 0 0 20px rgba(217,182,111,.12), 0 0 25px rgba(107,23,61,.25); }
.brand-orb { width: 42px; height: 42px; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: .7rem; margin-top: .1rem; }
.user-chip { display: flex; align-items: center; gap: .55rem; font-size: .85rem; }
.user-chip b { padding: .25rem .5rem; border-radius: 999px; background: rgba(107,23,61,.7); color: #f7dce8; font-size: .68rem; letter-spacing: .08em; }

.app-shell { width: min(1180px, calc(100% - 2rem)); margin: 1.5rem auto 4rem; display: grid; gap: 1rem; }
.hero-panel, .panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(31,22,28,.96), rgba(16,12,15,.96)); border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.hero-panel { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: clamp(1.25rem, 3vw, 2.2rem); overflow: hidden; position: relative; }
.hero-panel::after { content: ""; position: absolute; width: 250px; height: 250px; border: 1px solid rgba(217,182,111,.12); border-radius: 50%; right: -80px; top: -130px; box-shadow: 0 0 0 34px rgba(217,182,111,.025), 0 0 0 68px rgba(107,23,61,.035); }
.hero-panel h1 { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 500; margin: .25rem 0 .6rem; letter-spacing: .06em; }
.status-orb { z-index: 1; width: 116px; height: 116px; border-radius: 50%; display: grid; place-content: center; text-align: center; border: 1px solid var(--gold); background: rgba(11,8,10,.55); flex: none; }
.status-orb span, .status-orb strong { display: block; }
.status-orb span { color: var(--muted); font-size: .72rem; }
.status-orb strong { margin-top: .3rem; color: var(--gold-soft); font-size: .8rem; }
.panel { padding: clamp(1rem, 2.4vw, 1.6rem); min-width: 0; }
.panel h2 { margin: .2rem 0 1rem; font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-weight: 500; }
.panel h3 { margin: 0 0 .7rem; color: var(--gold-soft); font-size: 1rem; }
.eyebrow { margin: 0; color: var(--gold); font-size: .69rem; letter-spacing: .2em; font-weight: 800; }
.subtle, .hint, .privacy-note, .empty { color: var(--muted); }
.hint { font-size: .78rem; }
.privacy-note { text-align: center; font-size: .75rem; margin: 1rem 0 0; }
.grid { display: grid; gap: 1rem; min-width: 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.action-row { display: flex; flex-wrap: wrap; gap: .65rem; }
.action-row > * { flex: 1 1 120px; }
.action-panel .action-row { margin: 1.2rem 0 .7rem; }
.punch { min-height: 62px; font-size: 1rem; }
.inline-status { padding: .65rem .8rem; border-radius: 10px; background: rgba(255,255,255,.035); color: var(--muted); font-size: .82rem; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.live-indicator { color: var(--success); font-size: .76rem; padding: .35rem .65rem; border: 1px solid rgba(85,194,139,.3); border-radius: 999px; }
.live-indicator.offline { color: var(--warning); border-color: rgba(224,168,75,.3); }

.record-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); gap: .8rem; }
.record-card { min-width: 0; padding: 1rem; border: 1px solid rgba(255,255,255,.07); border-radius: 14px; background: rgba(255,255,255,.025); overflow-wrap: anywhere; }
.record-title { display: flex; justify-content: space-between; align-items: flex-start; gap: .7rem; margin-bottom: .75rem; }
.record-card dl { display: grid; gap: .45rem; margin: 0; }
.record-card dl div { display: grid; grid-template-columns: minmax(75px, .7fr) minmax(0, 1.3fr); gap: .7rem; align-items: baseline; }
.record-card dt { color: var(--muted); font-size: .72rem; }
.record-card dd { margin: 0; text-align: right; font-size: .83rem; }
.badge { flex: none; display: inline-flex; padding: .24rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--gold-soft); font-size: .64rem; letter-spacing: .05em; }
.badge.working, .badge.approved, .badge.finalized { color: #baf2d5; border-color: rgba(85,194,139,.35); background: rgba(28,94,62,.25); }
.badge.pending { color: #f6dca2; border-color: rgba(224,168,75,.4); }
.badge.returned, .badge.cancelled { color: #ffc1cb; border-color: rgba(229,91,109,.4); }
.money { color: var(--gold-soft); font-family: "Hiragino Mincho ProN", serif; font-size: 1.5rem; margin: .3rem 0; }
.money-small { color: var(--gold-soft); font-weight: 800; }
.plain-list { margin: .7rem 0; padding-left: 1.1rem; color: var(--muted); font-size: .84rem; }
.image-link { display: inline-block; padding: .55rem 0; }
.ticket-submission { padding-top: .8rem; margin-top: .8rem; border-top: 1px solid rgba(255,255,255,.08); }
.ticket-submission:first-of-type { margin-top: 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: .8rem; margin-top: 1rem; }
.owner-zone { border-color: rgba(217,182,111,.35); }

.stack-form { display: grid; gap: .85rem; }
.stack-form.compact { gap: .65rem; }
.stack-form label, fieldset { display: grid; gap: .35rem; color: var(--gold-soft); font-size: .8rem; }
fieldset { margin: 0; padding: .75rem; border: 1px solid var(--line); border-radius: 12px; }
legend { padding: 0 .35rem; }
input, select, textarea { width: 100%; min-width: 0; min-height: 46px; padding: .7rem .8rem; color: var(--text); background: rgba(5,4,5,.55); border: 1px solid rgba(255,255,255,.13); border-radius: 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217,182,111,.1); }
textarea { min-height: 80px; resize: vertical; }
input[type="file"] { padding: .55rem; }
input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--wine-bright); }
.check { grid-template-columns: auto 1fr; align-items: center; }
.quantity-row { grid-template-columns: 1fr 76px; align-items: center; }
.inline-form { display: grid; grid-template-columns: 70px 1fr auto; gap: .45rem; margin-top: .8rem; }
.inline-form input { min-height: 38px; padding: .45rem .55rem; }
.form-stack { display: grid; gap: .8rem; }
.form-stack > form { padding: 1rem; border: 1px solid rgba(255,255,255,.06); border-radius: 14px; }
.report-result { max-width: 100%; max-height: 28rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 1rem; border-radius: 12px; background: rgba(5,4,5,.55); color: var(--gold-soft); }
.audit-diff { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-top: .6rem; }
.audit-diff pre { max-width: 100%; overflow-wrap: anywhere; white-space: pre-wrap; padding: .65rem; border-radius: 8px; background: rgba(5,4,5,.55); color: var(--muted); }

.alert { padding: .85rem 1rem; border-radius: 12px; border: 1px solid; }
.alert.error { color: #ffd8df; border-color: rgba(229,91,109,.42); background: rgba(97,26,40,.35); }
.alert.warning { color: #ffe8b6; border-color: rgba(224,168,75,.42); background: rgba(92,62,15,.35); }
.toast { position: fixed; z-index: 30; left: 50%; top: 84px; transform: translate(-50%, -20px); width: min(92vw, 520px); padding: .8rem 1rem; border-radius: 12px; background: #21151b; border: 1px solid var(--line); opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: 0 15px 50px #0008; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { border-color: rgba(85,194,139,.45); }
.toast.error { border-color: rgba(229,91,109,.55); }

.auth-page { display: grid; place-items: center; padding: 1rem; }
.auth-shell { width: min(100%, 440px); }
.auth-card { padding: clamp(1.25rem, 5vw, 2rem); background: linear-gradient(145deg, rgba(32,22,29,.98), rgba(12,9,11,.98)); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 28px 80px rgba(0,0,0,.45); }
.auth-card.wide { width: min(100%, 520px); }
.auth-card .brand-mark { width: 74px; height: 74px; margin: 0 auto 1.2rem; font-family: "Hiragino Mincho ProN", serif; font-size: 1.65rem; }
.auth-card h1 { margin: .35rem 0 .2rem; text-align: center; font-family: "Hiragino Mincho ProN", serif; font-weight: 500; letter-spacing: .12em; }
.auth-card > .eyebrow, .auth-card > .subtle { text-align: center; }
.auth-card .stack-form { margin-top: 1.4rem; }
.qr { display: block; width: 220px; max-width: 100%; height: auto; margin: 1rem auto; padding: 8px; background: white; border-radius: 12px; }
.totp-secret { display: block; margin-top: .5rem; padding: .7rem; word-break: break-all; color: var(--gold-soft); }
footer { padding: 2rem 1rem 3rem; text-align: center; color: #77696f; font-size: .68rem; letter-spacing: .08em; }

@media (max-width: 720px) {
  .topbar { gap: .55rem; }
  .brand small, .user-chip span { display: none; }
  .app-shell { width: min(100% - 1rem, 1180px); margin-top: .5rem; }
  .grid.two { grid-template-columns: 1fr; }
  .audit-diff { grid-template-columns: 1fr; }
  .hero-panel { align-items: flex-start; }
  .status-orb { width: 86px; height: 86px; }
  .inline-form { grid-template-columns: 64px 1fr; }
  .inline-form button { grid-column: 1 / -1; }
}

@media (max-width: 390px) {
  .topbar { padding-inline: .5rem; }
  .brand-orb { width: 38px; height: 38px; }
  .topbar form button { padding-inline: .55rem; }
  .hero-panel { display: block; }
  .status-orb { width: auto; height: auto; border-radius: 10px; margin-top: .8rem; padding: .6rem; }
  .record-card dl div { grid-template-columns: 70px minmax(0, 1fr); }
  .section-heading { align-items: flex-start; }
}
