:root {
    --toami-red: #C8102E;
    --toami-red-hover: #A0001C;
    --toami-blue: #003087;
    --toami-blue-mid: #0047AB;
    --toami-blue-light: #0065B3;
    --toami-header-gradient: linear-gradient(135deg, #8B0000 0%, #C8102E 60%, #D4172B 100%);
    --font-jp: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Yu Gothic UI', 'Hiragino Sans', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-jp);
    background: #f0f4f9;
    color: #1e293b;
}

h1:focus { outline: none; }

.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid var(--toami-red); }
.validation-message { color: var(--toami-red); font-size: 0.8125rem; }

.blazor-error-boundary {
    background: var(--toami-red);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "エラーが発生しました。" }
.darker-border-checkbox.form-check-input { border-color: #929292; }

/* ===== 共通 Admin スタイル ===== */
.admin-container {
    min-height: calc(100vh - 56px);
    background: #f0f4f9;
    font-family: var(--font-jp);
}

.admin-header {
    background: var(--toami-header-gradient);
    padding: 1.75rem 2.5rem;
    box-shadow: 0 4px 24px rgba(200,16,46,0.35);
}

.admin-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.admin-title-area { display: flex; align-items: center; gap: 1rem; }

.admin-icon {
    width: 48px; height: 48px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.admin-icon svg { width: 26px; height: 26px; fill: rgba(255,255,255,0.9); }

.admin-title  { font-size: 1.5rem; font-weight: 700; color: #fff; margin: 0; letter-spacing: -0.02em; }
.admin-subtitle { font-size: 0.8rem; color: rgba(255,255,255,0.6); margin: 0.2rem 0 0; }

.header-actions { display: flex; align-items: center; gap: 1rem; }

.stat-badge {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
}
.stat-number { font-size: 1.75rem; font-weight: 700; color: #fff; line-height: 1; }
.stat-label  { font-size: 0.65rem; color: rgba(255,255,255,0.65); margin-top: 0.2rem; text-transform: uppercase; letter-spacing: 0.05em; }

.btn-primary {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.625rem 1.25rem;
    background: var(--toami-red); color: #fff;
    border: none; border-radius: 9px;
    font-size: 0.875rem; font-weight: 600;
    cursor: pointer; transition: background 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.btn-primary svg { width: 16px; height: 16px; fill: currentColor; }
.btn-primary:hover { background: var(--toami-red-hover); box-shadow: 0 2px 8px rgba(200,16,46,0.4); }

.admin-body { max-width: 1200px; margin: 0 auto; padding: 2rem 2.5rem 3rem; }

.alert {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-radius: 10px; font-size: 0.875rem; font-weight: 500;
    margin-bottom: 1.5rem;
}
.alert-icon { width: 20px; height: 20px; flex-shrink: 0; }
.alert-error  { background: #fff0f0; border: 1px solid #fecaca; border-left: 4px solid var(--toami-red); color: #7a000e; }
.alert-error .alert-icon { fill: var(--toami-red); }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; border-left: 4px solid #22c55e; color: #15803d; }
.alert-success .alert-icon { fill: #22c55e; }

.loading-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 5rem 0; }
.loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid #dde4ef; border-top-color: var(--toami-red);
    border-radius: 50%;
    animation: admin-spin 0.75s linear infinite;
    margin-bottom: 1rem;
}
@keyframes admin-spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 0.875rem; color: #7e8fa8; margin: 0; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 5rem 0; color: #94a3b8; }
.empty-icon  { width: 48px; height: 48px; fill: #cbd5e1; margin-bottom: 1rem; }

.table-wrapper {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(200,16,46,0.06), 0 8px 24px rgba(200,16,46,0.09);
    overflow: hidden;
    border: 1px solid rgba(200,16,46,0.07);
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table thead { background: linear-gradient(to right, #8B0000, #C8102E); }
.admin-table thead th {
    padding: 0.875rem 1.25rem;
    text-align: left; font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: rgba(255,255,255,0.8); border: none; white-space: nowrap;
}
.admin-table tbody tr { border-bottom: 1px solid #f1f5f9; transition: background 0.12s; }
.admin-table tbody tr:last-child { border-bottom: none; }
.admin-table tbody tr:hover { background: #fff5f5; }
.admin-table tbody tr.row-disabled { opacity: 0.55; }
.admin-table tbody td { padding: 0.875rem 1.25rem; vertical-align: middle; font-size: 0.875rem; color: #334155; }

.id-badge {
    font-family: 'SFMono-Regular', 'Consolas', monospace;
    font-size: 0.7rem; background: #f8f9fa; color: #475569;
    padding: 0.25rem 0.55rem; border-radius: 6px; border: 1px solid #cbd5e1;
    display: inline-block;
}
.col-name    { font-weight: 600; }
.text-muted  { color: #94a3b8; }
.col-actions { width: 1%; white-space: nowrap; }

.btn-action {
    padding: 0.35rem 0.875rem; border-radius: 7px;
    font-size: 0.8125rem; font-weight: 500; border: 1px solid;
    cursor: pointer; transition: background 0.15s, color 0.15s; margin-left: 0.35rem;
}
.btn-edit   { background: #f8fafc; color: #374151; border-color: #d1d5db; }
.btn-edit:hover   { background: #374151; color: #fff; }
.btn-delete { background: #fff0f0; color: var(--toami-red);  border-color: #fecaca; }
.btn-delete:hover { background: var(--toami-red);  color: #fff; }

.btn-danger { padding: 0.5rem 1.125rem; border-radius: 8px; font-size: 0.875rem; font-weight: 600; background: var(--toami-red); color: #fff; border: none; cursor: pointer; }
.btn-danger:hover { background: var(--toami-red-hover); }

.dialog-backdrop {
    position: fixed; inset: 0;
    background: rgba(60,0,10,0.45);
    backdrop-filter: blur(3px);
    z-index: 1000; display: flex; align-items: center; justify-content: center;
    padding: 1.5rem; animation: admin-fadeIn 0.15s ease;
}
@keyframes admin-fadeIn { from { opacity: 0; } to { opacity: 1; } }

.dialog-panel {
    background: #fff; border-radius: 16px;
    box-shadow: 0 20px 60px rgba(200,16,46,0.25);
    width: 100%; max-width: 600px; max-height: 90vh;
    display: flex; flex-direction: column;
    animation: admin-slideUp 0.2s ease; overflow: hidden;
}
.dialog-sm { max-width: 420px; }
@keyframes admin-slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.dialog-header {
    background: var(--toami-header-gradient);
    padding: 1.25rem 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.875rem; flex-shrink: 0;
}
.dialog-header-danger { background: linear-gradient(135deg, #7a000e, var(--toami-red)); }
.dialog-title-area    { display: flex; align-items: center; gap: 0.75rem; }
.dialog-header-icon   { width: 28px; height: 28px; fill: rgba(255,255,255,0.85); }
.dialog-title         { font-size: 1.0625rem; font-weight: 700; color: #fff; margin: 0; }

.dialog-close {
    width: 32px; height: 32px;
    border: none; background: rgba(255,255,255,0.12);
    border-radius: 7px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s; flex-shrink: 0;
}
.dialog-close:hover { background: rgba(255,255,255,0.22); }
.dialog-close svg { width: 16px; height: 16px; fill: rgba(255,255,255,0.85); }

.dialog-body   { padding: 1.5rem; overflow-y: auto; flex: 1; }
.dialog-footer {
    padding: 1rem 1.5rem; background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex; justify-content: flex-end; gap: 0.75rem;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-full  { grid-column: 1 / -1; }
.form-label { font-size: 0.8125rem; font-weight: 600; color: #374151; }
.required   { color: var(--toami-red); }
.form-hint  { font-size: 0.75rem; color: #64748b; }
.form-input {
    padding: 0.5rem 0.75rem; border: 1px solid #d1d5db;
    border-radius: 8px; font-size: 0.875rem;
    outline: none; transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff; color: #1e293b; width: 100%;
}
.form-input:focus  { border-color: var(--toami-red); box-shadow: 0 0 0 3px rgba(200,16,46,0.12); }
.form-input:disabled { background: #f1f5f9; color: #64748b; cursor: not-allowed; }
.form-error { color: var(--toami-red); font-size: 0.8125rem; margin-top: 0.75rem; }

.toggle-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.875rem; color: #374151; }

.btn-cancel {
    padding: 0.5rem 1.125rem; border-radius: 8px; font-size: 0.875rem; font-weight: 500;
    background: #fff; color: #374151; border: 1px solid #d1d5db; cursor: pointer; transition: background 0.15s;
}
.btn-cancel:hover { background: #f9fafb; }
.btn-save {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.5rem 1.25rem; border-radius: 8px; font-size: 0.875rem; font-weight: 600;
    background: var(--toami-red); color: #fff; border: none; cursor: pointer; transition: background 0.15s;
}
.btn-save:hover:not(:disabled) { background: var(--toami-red-hover); }
.btn-save:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
    border-radius: 50%; animation: admin-spin 0.7s linear infinite;
}

.active-badge   { font-size: 0.7rem; font-weight: 600; background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; border-radius: 20px; padding: 0.2rem 0.6rem; }
.inactive-badge { font-size: 0.7rem; font-weight: 600; background: #fff0f0; color: var(--toami-red); border: 1px solid #fecaca; border-radius: 20px; padding: 0.2rem 0.6rem; }
.kengen-badge   { font-size: 0.75rem; font-weight: 600; background: #fff0f0; color: var(--toami-red); border: 1px solid #fecaca; border-radius: 6px; padding: 0.2rem 0.5rem; }

@media (max-width: 768px) {
    .admin-header       { padding: 1.25rem 1rem; }
    .admin-header-inner { flex-direction: column; align-items: flex-start; }
    .admin-body         { padding: 1.25rem 1rem 2rem; }
    .form-grid          { grid-template-columns: 1fr; }
    .form-full          { grid-column: 1; }
    .admin-table thead th, .admin-table tbody td { padding: 0.75rem 1rem; }
}
