:root {
    --accent: #1F6FB2;
    --accent-dark: #14304A;
    --bg: #f4f6f9;
    --sidebar: #14304A;
    --border: #e2e8f0;
    --text: #1f2937;
    --muted: #6b7280;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: "맑은 고딕", "Malgun Gothic", -apple-system, Segoe UI, Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}

.loading-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: var(--muted);
}

/* 레이아웃 */
.page { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px;
    background: var(--sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

main { flex: 1; min-width: 0; }
.content { padding: 28px 32px; }

/* 사이드바 */
.nav-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
.nav-logo {
    background: var(--accent);
    width: 34px; height: 34px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.nav-title { font-size: 18px; font-weight: 600; }

.nav-links { display: flex; flex-direction: column; padding: 12px 8px; gap: 4px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 15px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { width: 20px; text-align: center; }
.nav-footer { margin-top: auto; padding: 16px 18px; border-top: 1px solid rgba(255,255,255,0.12); }
.nav-user { font-size: 14px; color: #e2e8f0; margin-bottom: 10px; }
.nav-logout {
    width: 100%;
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 8px;
    padding: 9px 12px;
    cursor: pointer;
    font-size: 14px;
}
.nav-logout:hover { background: rgba(255,255,255,0.16); }

/* 콘텐츠 */
h1 { font-size: 26px; margin: 0 0 16px; color: var(--accent-dark); }
.lead { color: var(--muted); max-width: 720px; line-height: 1.6; }
.status { color: var(--muted); margin: 8px 0 16px; }

/* 대시보드 카드 */
.card-grid { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 20px; }
.info-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    min-width: 220px;
    flex: 1;
}
.info-card-link { cursor: pointer; transition: transform .08s ease, box-shadow .08s ease; }
.info-card-link:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(20,48,74,0.12); border-color: var(--accent); }
.info-card-title { font-size: 13px; color: var(--muted); }
.info-card-value { font-size: 20px; font-weight: 700; color: var(--accent-dark); margin: 6px 0; }
.info-card-desc { font-size: 13px; color: var(--muted); }

/* 검색/필터 툴바 */
.toolbar { display: flex; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
.search-input {
    flex: 1;
    min-width: 220px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,111,178,0.15); }
.filter-select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

/* 테이블 */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.data-table th {
    background: var(--accent);
    color: #fff;
    text-align: left;
    padding: 12px 14px;
    font-size: 14px;
}
.data-table td { padding: 11px 14px; border-top: 1px solid var(--border); font-size: 14px; }
.data-table tbody tr:nth-child(even) { background: #f8fafc; }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-on { background: #dcfce7; color: #166534; }
.badge-off { background: #fee2e2; color: #991b1b; }
.badge-wait { background: #fef3c7; color: #92400e; }
.badge-req { background: #dbeafe; color: #1e40af; }
.badge-bal { background: #ffedd5; color: #9a3412; }

/* 오류 알림 */
.alert {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 18px 20px;
    max-width: 560px;
}
.alert-detail { font-size: 12px; color: var(--muted); font-family: monospace; }
.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 14px;
}
.btn:hover { background: #195d96; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f1f5f9; }

/* 행 액션 / 작은 버튼 */
.row-actions { white-space: nowrap; }
.btn-sm {
    background: #fff; color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 6px; padding: 4px 10px; font-size: 13px; cursor: pointer;
    margin-right: 4px;
}
.btn-sm:hover { background: #f1f5f9; }
.btn-danger { color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }

/* 등록/수정 폼 패널 */
.editor {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 18px 20px; margin-bottom: 16px;
}
.editor-title { font-weight: 700; color: var(--accent-dark); margin-bottom: 14px; }
.editor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.editor-actions { display: flex; gap: 8px; margin-top: 16px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.check input { width: auto; }

/* 로그인 화면 */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    padding: 20px;
}
.login-card {
    background: #fff;
    width: 100%;
    max-width: 380px;
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 18px 40px rgba(0,0,0,0.25);
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-logo {
    background: var(--accent);
    color: #fff;
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px;
}
.login-name { font-size: 20px; font-weight: 700; color: var(--accent-dark); }
.login-sub { color: var(--muted); font-size: 14px; margin: 12px 0 22px; }

.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,111,178,0.15); }

.btn-block { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
.login-error { color: #b91c1c; font-size: 13px; margin: 0 0 12px; }
.login-hint { color: var(--muted); font-size: 12px; margin-top: 18px; text-align: center; }
.login-hint code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }

/* 준비 중 자리표시 화면 */
.stub {
    background: #fff;
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    max-width: 560px;
}
.stub-icon { font-size: 40px; margin-bottom: 12px; }
.stub-title { font-size: 17px; font-weight: 600; color: var(--accent-dark); margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }

/* Blazor 기본 오류 UI */
#blazor-error-ui {
    background: #ffeb3b;
    bottom: 0;
    display: none;
    left: 0;
    padding: 0.8rem 1.4rem;
    position: fixed;
    width: 100%;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: 0.8rem; }

@media (max-width: 640px) {
    .sidebar { width: 64px; }
    .nav-title, .nav-footer, .nav-item span:last-child { display: none; }
    .content { padding: 18px; }
}
