:root {
    --bg: #f7f8fa;
    --bg-sidebar: #1c2333;
    --sidebar-active-bg: #2a3348;
    --sidebar-text: #9aa5b8;
    --sidebar-text-muted: #6b7690;
    --bg-card: #ffffff;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #2f6fed;
    --accent-bg: #eaf1ff;
    --success-bg: #dcfce7;
    --success-text: #15803d;
    --warning-bg: #fef3c7;
    --warning-text: #b45309;
    --danger-bg: #fee2e2;
    --danger-text: #dc2626;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text-primary);
    font-size: 13.5px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 210px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}
.sidebar-brand { padding: 0 1rem 1.25rem; }
.sidebar-brand a { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; text-decoration: none; }
.sidebar-group { color: var(--sidebar-text-muted); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; padding: 16px 1rem 6px; }
.sidebar-group:first-of-type { padding-top: 0; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 1rem 9px 18px;
    color: var(--sidebar-text);
    font-size: 14px;
    border-left: 2px solid transparent;
    text-decoration: none;
}
.sidebar-link:hover { color: #fff; text-decoration: none; }
.sidebar-link.active {
    color: #fff;
    background: var(--sidebar-active-bg);
    border-left: 2px solid var(--accent);
    padding-left: 16px;
    font-weight: 500;
}
.sidebar-link i { font-size: 17px; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 0.5px solid var(--border);
    background: var(--bg-card);
}
.breadcrumb { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .crumb-sep { margin: 0 6px; color: var(--border-strong); }
.breadcrumb .crumb-current { color: var(--text-primary); }

.topbar-account { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.topbar-account a { color: var(--text-secondary); }
.topbar-account .account-name { color: var(--text-primary); font-weight: 500; }
.bell-link { position: relative; display: inline-flex; color: var(--text-secondary); }
.bell-link i { font-size: 18px; }
.bell-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--danger-text);
    color: #fff;
    font-size: 10px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 8px;
    font-weight: 600;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.content { max-width: 960px; margin: 0 auto; padding: 24px 20px; width: 100%; }

.tabbar {
    display: flex;
    gap: 4px;
    padding: 10px 20px 0;
    border-bottom: 0.5px solid var(--border);
    background: var(--bg-card);
}
.tabbar a {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    text-decoration: none;
}
.tabbar a.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

h1, h2 { color: var(--text-primary); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 19px; margin: 0 0 16px; }
h2 { font-size: 15px; margin-top: 24px; }

.kpi-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 8px; padding: 14px; }
.kpi-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-top: 2px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
}
.data-table th, .data-table td {
    border-top: 0.5px solid var(--border);
    padding: 11px 12px;
    text-align: left;
    color: var(--text-primary);
}
.data-table thead tr { border-top: none; }
.data-table th { background: #fafbfc; color: var(--text-secondary); font-weight: 600; font-size: 12px; border-top: none; }

.badge { font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 8px; }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-neutral { background: var(--border); color: var(--text-secondary); }

.overdue { color: var(--danger-text); font-weight: 600; }

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
}
.hamburger:hover { background: none; }
.sidebar-backdrop { display: none; }

button.help-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
    align-items: center;
}
button.help-icon:hover { color: var(--text-primary); background: none; }
button.help-icon i { font-size: 18px; }

dialog#help-dialog {
    position: relative;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 0.5px solid var(--border);
    border-radius: 8px;
    max-width: 560px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
dialog#help-dialog::backdrop { background: rgba(17,24,39,0.6); }
dialog#help-dialog h2 { margin-top: 0; padding-right: 28px; }
dialog#help-dialog h3 { font-size: 14px; color: var(--text-primary); margin: 18px 0 6px; font-weight: 600; }
dialog#help-dialog p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin: 0 0 4px; }
dialog#help-dialog .help-close { margin-top: 20px; }
dialog#help-dialog .dialog-close-x {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
}
dialog#help-dialog .dialog-close-x:hover { color: var(--text-primary); background: none; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -220px;
        top: 0;
        bottom: 0;
        z-index: 100;
        transition: left 0.2s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,0.25);
    }
    .sidebar.open { left: 0; }
    .hamburger { display: inline-flex; align-items: center; }
    .sidebar-backdrop.visible {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(17,24,39,0.5);
        z-index: 99;
    }
    .kpi-row { grid-template-columns: 1fr; }
    .content { padding: 16px 12px; }
    .topbar { padding: 10px 12px; gap: 8px; }
    .topbar-account { gap: 8px; font-size: 12px; }
    .topbar-account .account-name { display: none; }
    .data-table { display: block; overflow-x: auto; white-space: nowrap; }
    .login-box { width: 90vw; max-width: 320px; }
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-sidebar);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.login-box {
    background: var(--bg-card);
    padding: 32px;
    border-radius: 10px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.login-box h1 { margin: 0; }
.login-box label { display: flex; flex-direction: column; font-size: 13.5px; gap: 4px; color: var(--text-secondary); font-weight: 500; }
.login-box input {
    padding: 8px 10px;
    font-size: 14px;
    background: #fff;
    border: 0.5px solid var(--border-strong);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
}
.login-box button {
    padding: 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
}

.error { color: var(--danger-text); font-size: 13px; }
.success { color: var(--success-text); font-size: 13px; }

.form-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    margin-top: 16px;
    border: 0.5px solid var(--border);
}
.form-box label { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--text-secondary); font-weight: 500; }
.form-box input, .form-box select {
    padding: 8px 10px;
    font-size: 14px;
    background: #fff;
    border: 0.5px solid var(--border-strong);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
}
.form-box button {
    padding: 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
}

button {
    padding: 6px 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 0.5px solid var(--border-strong);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}
button:hover { background: #f3f4f6; }

select {
    background: #fff;
    color: var(--text-primary);
    border: 0.5px solid var(--border-strong);
    border-radius: 6px;
    padding: 4px 8px;
    font-family: inherit;
}

.password-field { position: relative; display: flex; }
.password-field input { flex: 1; padding-right: 34px; }
button.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}
button.password-toggle:hover { color: var(--text-primary); background: none; }
button.password-toggle i { font-size: 16px; }

.plain-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plain-list li { background: var(--bg-card); border: 0.5px solid var(--border); padding: 10px 12px; border-radius: 6px; display: flex; align-items: center; gap: 10px; color: var(--text-primary); }

.ts-note { font-size: 13px; color: var(--text-secondary); margin-top: -4px; }
