/* Sekisho Admin — HeroUI 風ダークテーマ
   トークンは HeroUI (NextUI) dark theme 準拠:
   background #000 / content1 #18181b / content2 #27272a / primary #006FEE */

:root {
    color-scheme: dark;
    --bg: #000000;
    --content1: #18181b;
    --content2: #27272a;
    --content3: #3f3f46;
    --fg: #ECEDEE;
    --fg-secondary: #a1a1aa;
    --fg-muted: #71717a;
    --divider: rgba(255, 255, 255, 0.12);
    --primary: #006FEE;
    --primary-hover: #338EF7;
    --primary-soft: rgba(0, 111, 238, 0.20);
    --success: #17c964;
    --warning: #f5a524;
    --warning-soft: rgba(245, 165, 36, 0.15);
    --danger: #f31260;
    --danger-soft: rgba(243, 18, 96, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: "Inter", "Segoe UI", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
    background: var(--bg);
    color: var(--fg);
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }
h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; margin: 0; display: flex; align-items: center; gap: .6rem; }
h2 { font-size: .95rem; font-weight: 600; margin: 0 0 .9rem; color: var(--fg); }
a { color: var(--primary-hover); text-decoration: none; }
a:hover { opacity: .85; }
code {
    background: var(--content2);
    padding: .12rem .4rem;
    border-radius: var(--radius-sm);
    font-size: .85em;
    color: var(--fg-secondary);
}
.muted { color: var(--fg-muted); }
.error { color: var(--danger); }

/* ---- 起動/ログイン ---- */
.boot {
    height: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-muted);
}
.login-card {
    background: var(--content1);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.2rem 2.4rem;
    width: min(92vw, 25rem);
    display: flex;
    flex-direction: column;
    gap: .8rem;
}
.login-card h1 { justify-content: center; }
.login-card p { margin: 0; text-align: center; color: var(--fg-secondary); }
.login-card label { color: var(--fg-secondary); font-size: .8rem; font-weight: 500; }
.dev-code { color: var(--warning); }

/* ---- レイアウト ---- */
.page { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--bg);
    border-right: 1px solid var(--divider);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { font-weight: 700; font-size: 1.02rem; padding: 1.2rem 1.2rem 1rem; letter-spacing: -0.01em; }
.sidebar nav { flex: 1; overflow-y: auto; padding: .3rem .6rem; }
.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .55rem .75rem;
    margin: .15rem 0;
    color: var(--fg-secondary);
    border-radius: var(--radius-md);
    transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--content1); color: var(--fg); opacity: 1; }
.nav-item.active { background: var(--content2); color: var(--fg); font-weight: 600; }
.nav-app-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-section {
    padding: 1.1rem .75rem .35rem;
    font-size: .68rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--fg-muted);
    font-weight: 600;
}
.nav-empty { padding: .4rem .75rem; color: var(--fg-muted); font-size: .85rem; }
.sidebar-footer { border-top: 1px solid var(--divider); padding: .9rem 1.2rem; display: flex; flex-direction: column; gap: .5rem; }
.sidebar-footer .email { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; }
.content { flex: 1; padding: 1.6rem 2rem 3rem; min-width: 0; }

/* ---- ヘッダ行・期間切替（HeroUI Tabs 風セグメント） ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.range-picker {
    display: inline-flex;
    gap: .15rem;
    background: var(--content1);
    padding: .25rem;
    border-radius: var(--radius-md);
}
.btn-range {
    background: transparent;
    border: none;
    color: var(--fg-muted);
    border-radius: var(--radius-sm);
    padding: .35rem .8rem;
    font-size: .82rem;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.btn-range:hover:not(.active) { color: var(--fg-secondary); }
.btn-range.active { background: var(--content3); color: var(--fg); font-weight: 600; }

/* ---- ボタン・入力（HeroUI Button / Input 風） ---- */
.btn {
    background: var(--content2);
    color: var(--fg);
    border: none;
    border-radius: var(--radius-md);
    padding: .55rem 1.1rem;
    cursor: pointer;
    font-size: .88rem;
    font-weight: 500;
    font-family: inherit;
    transition: background .15s, opacity .15s, transform .1s;
}
.btn:hover:not(:disabled) { opacity: .85; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); opacity: 1; }
.btn-ghost { background: transparent; border: 1.5px solid var(--content3); color: var(--fg-secondary); }
.btn-ghost:hover:not(:disabled) { border-color: var(--fg-muted); color: var(--fg); opacity: 1; }
.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    padding: .3rem .7rem;
    font-size: .8rem;
    border-radius: 999px;
}

input, select {
    background: var(--content2);
    color: var(--fg);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    padding: .55rem .8rem;
    font-size: .92rem;
    font-family: inherit;
    transition: border-color .15s, background .15s;
}
input::placeholder { color: var(--fg-muted); }
input:hover, select:hover { background: var(--content3); }
input:focus, select:focus { outline: none; border-color: var(--primary); background: var(--content2); }
.search-row { display: flex; gap: .6rem; margin-bottom: 1.2rem; }
.search-row input { flex: 1; max-width: 26rem; }

/* ---- タイル（HeroUI Card 風） ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: .9rem; margin-bottom: 1.3rem; }
.tile {
    background: var(--content1);
    border-radius: var(--radius-lg);
    padding: 1.05rem 1.15rem;
    box-shadow: var(--shadow-md);
}
.tile-label { font-size: .76rem; color: var(--fg-muted); margin-bottom: .35rem; font-weight: 500; }
.tile-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---- パネル・テーブル ---- */
.panel {
    background: var(--content1);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.4rem;
    margin-bottom: 1.3rem;
    box-shadow: var(--shadow-md);
    overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .6rem .7rem; white-space: nowrap; }
.table thead th {
    color: var(--fg-muted);
    font-weight: 600;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: var(--content2);
}
.table thead th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.table thead th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.table tbody td { border-bottom: 1px solid var(--divider); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.kv th { color: var(--fg-muted); width: 10rem; font-weight: 500; text-transform: none; letter-spacing: 0; background: transparent; }
.table.inner { margin: .5rem 0 1rem; }
.row-click { cursor: pointer; transition: background .12s; }
.row-click:hover td { background: var(--content2); }
.detail-cell { background: var(--bg); padding: 1rem 1.1rem !important; white-space: normal !important; border-radius: var(--radius-md); }
.grant-form { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* ---- チップ（HeroUI Chip 風ピル） ---- */
.badge {
    font-size: .7rem;
    font-weight: 600;
    padding: .18rem .6rem;
    border-radius: 999px;
    white-space: nowrap;
}
.badge-sub { color: var(--primary-hover); background: var(--primary-soft); }
.badge-one { color: var(--fg-secondary); background: var(--content2); }
.status { font-size: .8rem; font-weight: 600; }
.status-active { color: var(--success); }
.status-canceled { color: var(--warning); }
.status-expired { color: var(--fg-muted); }

.notice {
    background: var(--warning-soft);
    border-radius: var(--radius-md);
    padding: .9rem 1.1rem;
    color: var(--warning);
    margin-bottom: 1.3rem;
    font-size: .9rem;
}

/* ---- チャート ---- */
.chart-card {
    background: var(--content1);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.4rem;
    margin-bottom: 1.3rem;
    box-shadow: var(--shadow-md);
}
.chart-title { color: var(--fg); font-size: .95rem; font-weight: 600; margin-bottom: .8rem; }
.chart-empty { padding: 2rem 0; text-align: center; }
.chart-svg { width: 100%; height: 240px; display: block; }
.chart-bar { fill: var(--primary); }
.chart-bar:hover { fill: var(--primary-hover); }
.chart-grid { stroke: var(--divider); stroke-width: 1; }
.chart-tick { fill: var(--fg-muted); font-size: 10px; }
.chart-label { fill: var(--fg-secondary); font-size: 11px; font-weight: 600; }

/* ---- Blazor エラー UI ---- */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: #fff;
    padding: .7rem 1.3rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
}
#blazor-error-ui .reload { color: #fff; text-decoration: underline; margin-left: .5rem; }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: .8rem; }

@media (max-width: 760px) {
    .page { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
}
