:root {
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --muted: #64748b;
  --text: #0f172a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif; }
h1, h2 { margin: 0 0 .6rem; font-weight: 700; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.02rem; display: flex; align-items: center; gap: .5rem; }
h2 i { color: var(--primary); }
.muted { color: var(--muted); font-size: .85rem; }
.small { font-size: .74rem; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a, #2563eb 55%, #38bdf8); }
.login-card { background: #fff; padding: 2.4rem 2rem; border-radius: 18px; width: 92%; max-width: 370px; box-shadow: 0 24px 60px rgba(2,6,23,.35); display: flex; flex-direction: column; gap: .85rem; text-align: center; }
.login-logo { font-size: 2.6rem; color: var(--primary); }
.login-card h1 { font-size: 1.15rem; }
.login-card input { padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 10px; font-size: 1rem; }
.login-card input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.err { color: #dc2626; font-size: .85rem; min-height: 1.1rem; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 1rem; background: #fff; padding: .7rem 1.2rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { font-weight: 700; display: flex; align-items: center; gap: .5rem; font-size: 1.02rem; flex-wrap: wrap; }
.brand i { color: var(--primary); }
/* アプリ名の横に出す注意書き（売上速報のため最終値と差異があり得る旨） */
.brand-note { font-size: .72rem; font-weight: 600; color: #b45309; background: #fffbeb; border: 1px solid #fde68a; border-radius: 999px; padding: .2rem .6rem; display: inline-flex; align-items: center; gap: .35rem; line-height: 1.2; }
.brand-note i { color: #d97706; font-size: .72rem; }
.tabs { display: flex; gap: .35rem; margin-left: auto; }
.tab { border: none; background: transparent; padding: .5rem .85rem; border-radius: 9px; cursor: pointer; font-size: .88rem; color: var(--muted); font-weight: 600; }
.tab.active { background: #eff6ff; color: var(--primary-d); }
.userbox { display: flex; align-items: center; gap: .5rem; }
.uname { font-size: .85rem; color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: .72rem; padding: .18rem .5rem; border-radius: 999px; font-weight: 700; }
.badge-admin { background: #dbeafe; color: #1e40af; }
.badge-viewer { background: #dcfce7; color: #166534; }
.badge-scope { background: #fef3c7; color: #92400e; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-off { background: #fee2e2; color: #991b1b; }

main { padding: 1.2rem; max-width: 1360px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1.1rem 1.2rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); }

/* buttons */
.btn { border: 1px solid var(--border); background: #fff; padding: .55rem .95rem; border-radius: 9px; cursor: pointer; font-size: .88rem; font-weight: 600; display: inline-flex; align-items: center; gap: .4rem; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: transparent; }
.btn.sm { padding: .35rem .6rem; font-size: .8rem; }
.btn.block { width: 100%; justify-content: center; padding: .75rem; }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.danger-card { border-color: #fecaca; }
.danger-card h2 i { color: #dc2626; }

/* filters */
.filters { display: flex; align-items: flex-end; gap: .8rem; flex-wrap: wrap; }
.filters.inline { padding: 0; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field label { font-size: .75rem; color: var(--muted); font-weight: 600; }
.field input, .field select { padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; font-size: .9rem; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.kpi { display: flex; gap: .8rem; align-items: center; }
.kpi-ico { width: 44px; height: 44px; border-radius: 12px; background: #eff6ff; color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0; }
.kpi-label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.5rem; font-weight: 800; line-height: 1.15; }
.kpi-sub { font-size: .72rem; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.chart-box { position: relative; height: 300px; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data th, table.data td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.data th { font-size: .75rem; color: var(--muted); font-weight: 700; background: #f8fafc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.nowrap, table.data th.nowrap { white-space: nowrap; }
table.data td code { background: #f1f5f9; padding: .12rem .4rem; border-radius: 5px; font-weight: 700; letter-spacing: .02em; }
.btn.all-day { border-color: #cbd5e1; color: var(--muted); }
.btn.all-day.primary { color: #fff; }
table.data tr:hover td { background: #f8fafc; }

.paybar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; margin-top: .7rem; }
.paybar span { display: block; background: var(--primary); }
.paybar span:nth-child(2) { background: #f59e0b; }
.paybar span:nth-child(3) { background: #10b981; }
.paybar span:nth-child(4) { background: #ec4899; }
.paybar span:nth-child(5) { background: #8b5cf6; }

.seat-group { margin-bottom: 1.1rem; }
.seat-store { font-weight: 700; margin-bottom: .5rem; font-size: .9rem; }
.seat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: .55rem; }
.seat-cell { border: 1px solid var(--border); border-radius: 10px; padding: .5rem; background: #fbfdff; }
.seat-cell-chuto { background: #fffbeb; border-color: #fde68a; }
.seat-store-occ { margin-left: .5rem; font-size: .76rem; font-weight: 700; color: #16a34a; background: #dcfce7; padding: .1rem .45rem; border-radius: 999px; }
.seat-no { font-weight: 700; font-size: .82rem; }
.seat-bar { height: 7px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: .35rem 0; }
.seat-bar i { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, #16a34a); }
.seat-pct { font-size: .92rem; font-weight: 700; }
.seat-sub { font-size: .68rem; color: var(--muted); }

.upload-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.upload-row input[type=text], .upload-row input[type=password] { padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; min-width: 220px; }

/* store scope picker (key issuance) */
.scope-picker { margin-top: .8rem; display: flex; flex-direction: column; gap: .5rem; }
.scope-all { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; font-weight: 600; cursor: pointer; }
.scope-stores { display: flex; flex-wrap: wrap; gap: .5rem; padding: .7rem .8rem; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; }
.scope-item { display: inline-flex; align-items: center; gap: .35rem; font-size: .84rem; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: .3rem .7rem; cursor: pointer; }
.scope-item:hover { border-color: var(--primary); }
.upload-result, .key-result { margin-top: .8rem; }
.ok-box, .err-box { display: flex; gap: .6rem; padding: .8rem 1rem; border-radius: 10px; font-size: .88rem; align-items: flex-start; }
.ok-box { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.err-box { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.key-box { display: flex; align-items: center; gap: .6rem; background: #f8fafc; border: 1px dashed var(--border); border-radius: 10px; padding: .7rem 1rem; flex-wrap: wrap; }
.key-box code { font-size: 1.05rem; font-weight: 700; letter-spacing: .04em; color: var(--primary-d); background: #fff; padding: .3rem .6rem; border-radius: 6px; }

/* usage panel (data volume / retention) */
.usage-panel { margin-top: .6rem; }
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; margin-bottom: .6rem; }
.usage-stat { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: .7rem .85rem; }
.usage-stat-label { font-size: .74rem; color: var(--muted); font-weight: 700; margin-bottom: .25rem; }
.usage-stat-value { font-size: 1.25rem; font-weight: 800; color: var(--primary-d); font-variant-numeric: tabular-nums; line-height: 1.15; }
.usage-stat-value small { font-size: .72rem; font-weight: 600; color: var(--muted); }
.usage-h3 { font-size: .88rem; margin: .9rem 0 .45rem; color: #334155; }
.usage-limit { margin-bottom: .55rem; }
.usage-limit-head { display: flex; justify-content: space-between; gap: .6rem; font-size: .8rem; font-weight: 600; margin-bottom: .28rem; }
.usage-bar { height: 9px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.usage-bar-fill { height: 100%; background: linear-gradient(90deg, #22c55e, #16a34a); border-radius: 999px; transition: width .3s ease; }

/* Doretoru API 同期パネル */
.sync-panel { margin-top: .6rem; }
.sync-edit-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: .8rem .9rem; }
.sync-edit-box .field input { min-width: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* toast */
.toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%) translateY(140%); background: #0f172a; color: #fff; padding: .7rem 1.2rem; border-radius: 10px; font-size: .88rem; transition: transform .28s ease; z-index: 60; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: #b91c1c; }
