:root {
    --sidebar-bg: #0f1c2e;
    --sidebar-hover: #1a2d45;
    --sidebar-active: #2563eb;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #7c3aed;
    --orange: #f97316;
    --bg: #f3f5f9;
    --card: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --muted: #6b7280;
    --input-bg: #fafbff;
    --table-head: #fafbfc;
    --table-hover: #f8fafc;
    --calc-bg: #f8fafc;
    --topbar-search-bg: #f9fafb;
    --sidebar-w: 250px;
    --sidebar-collapsed-w: 78px;
    --header-h: 64px;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
    --font: "DM Sans", "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
    --sidebar-bg: #0a0f1a;
    --sidebar-hover: #151d2e;
    --sidebar-active: #2563eb;
    --bg: #0b1220;
    --card: #111827;
    --border: #243044;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --input-bg: #0f172a;
    --table-head: #0f172a;
    --table-hover: #152033;
    --calc-bg: #0f172a;
    --topbar-search-bg: #0f172a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background .2s ease, color .2s ease;
}

a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; }

/* ========== LOGIN ========== */
.login-body {
    min-height: 100vh;
    background: #f4f7fe;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 1.05fr) minmax(360px, 1fr);
}

.login-aside {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.45), transparent 42%),
        radial-gradient(circle at 85% 75%, rgba(59, 130, 246, 0.28), transparent 40%),
        linear-gradient(165deg, #0b1437 0%, #0f1c2e 55%, #13233d 100%);
    color: #fff;
    padding: 40px 48px;
    display: flex;
    align-items: stretch;
}

.login-aside-glow {
    position: absolute;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    right: -80px;
    bottom: -100px;
    background: rgba(37, 99, 235, 0.35);
    filter: blur(40px);
    pointer-events: none;
}

.login-aside-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.login-aside-brand,
.login-card-mobile-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-aside-brand .logo-mark,
.login-card-mobile-brand .logo-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
}

.login-aside-brand span,
.login-card-mobile-brand span {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-aside-copy {
    margin-top: auto;
    padding-top: 80px;
}

.login-aside-copy h1 {
    font-size: clamp(28px, 3.2vw, 40px);
    line-height: 1.15;
    letter-spacing: -0.035em;
    font-weight: 700;
    margin-bottom: 14px;
    max-width: 420px;
}

.login-aside-copy p {
    color: #94a3b8;
    font-size: 15px;
    line-height: 1.65;
    max-width: 380px;
}

.login-aside-points {
    list-style: none;
    margin-top: 40px;
    display: grid;
    gap: 14px;
}

.login-aside-points li {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
}

.login-aside-points .point-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: grid;
    place-items: center;
    color: #60a5fa;
    flex-shrink: 0;
}

.login-main {
    display: grid;
    place-items: center;
    padding: 40px 24px;
    background:
        radial-gradient(circle at 90% 10%, rgba(37, 99, 235, 0.08), transparent 28%),
        #f4f7fe;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
    padding: 40px 36px;
    border: 1px solid #eef2f7;
    animation: loginFadeUp .45s ease both;
}

@keyframes loginFadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card-mobile-brand {
    display: none;
    margin-bottom: 28px;
    color: var(--text);
}

.login-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 10px;
}

.login-card h2 {
    font-size: 28px;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
    color: #1b2559;
    font-weight: 700;
}

.login-card .subtitle {
    color: #a3aed0;
    font-size: 14px;
    margin-bottom: 28px;
    line-height: 1.5;
}

.login-form .form-group { margin-bottom: 18px; }

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.input-icon {
    position: relative;
}

.input-icon > svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #a3aed0;
    pointer-events: none;
}

.input-icon .form-control {
    padding-left: 44px;
}

.form-control {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--input-bg);
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.form-control::placeholder { color: var(--muted); }

.form-control:hover { border-color: var(--primary); }

.form-control:focus {
    border-color: var(--primary);
    background: var(--card);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

textarea.form-control {
    height: auto;
    padding: 12px 14px;
    resize: vertical;
}

.login-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #707eae;
    cursor: pointer;
    user-select: none;
}

.form-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s, box-shadow .15s;
}

.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.35);
}
.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    box-shadow: 0 10px 24px rgba(22, 163, 74, 0.28);
}
.btn-success:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
}
.btn-danger {
    background: linear-gradient(135deg, #f87171, #ef4444);
    color: #fff;
    box-shadow: 0 10px 24px rgba(239, 68, 68, 0.28);
}
.btn-danger:hover {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}
.btn-outline {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--input-bg); }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }

.login-submit {
    height: 50px;
    font-size: 15px;
    border-radius: 14px;
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13px;
    margin-bottom: 18px;
}
.alert-danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

.login-hint {
    margin-top: 24px;
    padding: 14px 16px;
    background: #f4f7fe;
    border-radius: 12px;
    border: 1px dashed #d0d7ea;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #707eae;
}

.login-hint span {
    width: 100%;
    font-weight: 600;
    color: #2b3674;
    margin-bottom: 2px;
}

.login-hint code {
    background: #fff;
    border: 1px solid #e0e5f2;
    color: #2563eb;
    padding: 4px 8px;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

@media (max-width: 960px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-aside { display: none; }
    .login-card-mobile-brand { display: flex; }
    .login-main { padding: 28px 16px; min-height: 100vh; }
    .login-card { padding: 28px 22px; border-radius: 18px; }
    .login-card h2 { font-size: 24px; }
}

/* ========== LAYOUT ========== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: width .25s ease, transform .25s ease;
    overflow: hidden;
}

.sidebar-brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}

.sidebar-brand .logo-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-brand span {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.02em;
    opacity: 1;
    transition: opacity .2s ease;
}

.sidebar-nav {
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #94a3b8;
    transition: background .15s, color .15s;
    white-space: nowrap;
}

.nav-item .nav-label {
    opacity: 1;
    transition: opacity .2s ease;
}

.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

/* Collapsed sidebar (desktop) */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-w);
}
body.sidebar-collapsed .sidebar-brand {
    padding: 0;
    justify-content: center;
}
body.sidebar-collapsed .sidebar-brand span,
body.sidebar-collapsed .nav-item .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
}
body.sidebar-collapsed .sidebar-nav {
    padding: 18px 12px;
}
body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px;
    gap: 0;
}
body.sidebar-collapsed .main-wrap {
    margin-left: var(--sidebar-collapsed-w);
}

.main-wrap {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
}

.topbar {
    height: var(--header-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
    transition: background .2s ease, border-color .2s ease;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.menu-toggle {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    color: var(--text);
    flex-shrink: 0;
    transition: background .15s, border-color .15s;
}
.menu-toggle:hover {
    background: var(--input-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.topbar-search {
    flex: 1;
    max-width: 420px;
    position: relative;
}

.topbar-search svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--muted);
}

.topbar-search input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--topbar-search-bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.topbar-search input:focus {
    background: var(--card);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon,
html:not([data-theme]) .theme-toggle .icon-moon { display: block; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    display: grid;
    place-items: center;
    cursor: pointer;
    position: relative;
    color: var(--muted);
    transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--input-bg);
}

.icon-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: grid;
    place-items: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 14px;
}

.user-menu span { font-size: 14px; font-weight: 600; }
.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    min-width: 160px;
    overflow: hidden;
    z-index: 60;
}
.user-menu.open .user-dropdown { display: block; }
.user-dropdown button,
.user-dropdown a {
    display: block;
    width: 100%;
    padding: 11px 14px;
    text-align: left;
    background: none;
    border: none;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
}
.user-dropdown button:hover,
.user-dropdown a:hover { background: var(--input-bg); }

.content { padding: 28px; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-head h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.page-head .desc { color: var(--muted); font-size: 14px; }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    margin-top: 8px;
}

.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { opacity: 0.5; }

/* ========== KPI CARDS ========== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.kpi-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: background .2s ease, border-color .2s ease;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-icon.blue { background: #dbeafe; color: #2563eb; }
.kpi-icon.green { background: #dcfce7; color: #16a34a; }
.kpi-icon.purple { background: #ede9fe; color: #7c3aed; }
.kpi-icon.orange { background: #ffedd5; color: #ea580c; }
html[data-theme="dark"] .kpi-icon.blue { background: rgba(37, 99, 235, 0.2); }
html[data-theme="dark"] .kpi-icon.green { background: rgba(22, 163, 74, 0.2); }
html[data-theme="dark"] .kpi-icon.purple { background: rgba(124, 58, 237, 0.2); }
html[data-theme="dark"] .kpi-icon.orange { background: rgba(234, 88, 12, 0.2); }

.kpi-card .label {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 4px;
}
.kpi-card .value {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ========== FILTERS ========== */
.filter-card {
    --filter-control-h: 40px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 22px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filter-field { flex: 1; min-width: 160px; }
.filter-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
}

.filter-card input.form-control,
.filter-card select.form-control,
.filter-card .range-btn,
.filter-card .btn,
.filter-card .btn-sm,
.filter-card a.btn {
    height: var(--filter-control-h) !important;
    min-height: var(--filter-control-h) !important;
    max-height: var(--filter-control-h) !important;
    box-sizing: border-box;
    border-radius: 10px;
    font-size: 13px;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.filter-card input.form-control,
.filter-card select.form-control {
    padding-left: 12px;
    padding-right: 12px;
    line-height: normal;
    border: 1px solid var(--border);
    background: var(--input-bg);
}

.filter-card select.form-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    cursor: pointer;
}

.filter-card .form-control:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.range-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    min-height: var(--filter-control-h);
}

.range-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--filter-control-h);
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}
.range-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.filter-actions .btn {
    padding-left: 14px;
    padding-right: 14px;
    line-height: 1;
    box-shadow: none;
}

/* ========== TABLE ========== */
.table-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}

.table-toolbar .show-entries {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}

.table-toolbar select {
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 10px;
    background: var(--card);
    color: var(--text);
}

.table-search {
    position: relative;
    width: 240px;
}

.table-search input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: var(--input-bg);
    color: var(--text);
}

.table-search svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1100px;
}

table.data-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--table-head);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table td {
    padding: 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
}

table.data-table tbody tr:hover { background: var(--table-hover); }

.customer-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
}

.currency-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.flag {
    width: 22px;
    height: 16px;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(0,0,0,.08);
    background: #e5e7eb;
    display: inline-block;
    font-size: 14px;
    line-height: 16px;
    text-align: center;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.status-pill.paid { background: #dcfce7; color: #15803d; }
.status-pill.pending { background: #ffedd5; color: #c2410c; }
.status-pill.failed { background: #fee2e2; color: #b91c1c; }
.status-pill.deleted { background: #e5e7eb; color: #4b5563; }
html[data-theme="dark"] .status-pill.deleted { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }

.action-menu { position: relative; }
.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--muted);
    display: grid;
    place-items: center;
}
.action-btn:hover { background: var(--input-bg); color: var(--text); }
.action-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    min-width: 140px;
    z-index: 20;
    overflow: hidden;
}
.action-menu.open .action-dropdown { display: block; }
.action-dropdown form { margin: 0; }
.action-dropdown button {
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
}
.action-dropdown button:hover { background: var(--input-bg); }
.action-dropdown button.action-success { color: #15803d; }
.action-dropdown button.action-success:hover { background: rgba(34, 197, 94, 0.12); }
.action-dropdown button.action-danger { color: var(--danger); }
.action-dropdown button.action-danger:hover { background: rgba(239, 68, 68, 0.12); }

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    gap: 12px;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--muted);
}

.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.pagination .active span {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination .disabled span {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========== DRAWER ========== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s;
    z-index: 200;
}
.drawer-overlay.open { opacity: 1; visibility: visible; }

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 440px;
    height: 100%;
    background: var(--card);
    color: var(--text);
    z-index: 210;
    transform: translateX(100%);
    transition: transform .28s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 40px rgba(15, 23, 42, 0.15);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}
.drawer-header h3 { font-size: 18px; font-weight: 700; }
.drawer-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--input-bg);
    border-radius: 8px;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.drawer-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}

.drawer-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
}

.drawer-footer .btn { flex: 1; }

/* Conversion radio cards */
.conversion-radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.conversion-radio {
    display: block;
    cursor: pointer;
    margin: 0;
}
.conversion-radio input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.conversion-radio-ui {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--input-bg);
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.conversion-radio-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--muted);
    flex-shrink: 0;
    position: relative;
    transition: border-color .15s, background .15s;
}
.conversion-radio-dot::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: transparent;
    transition: background .15s;
}
.conversion-radio-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.conversion-radio-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}
.conversion-radio-sub {
    font-size: 12px;
    color: var(--muted);
}
.conversion-radio:hover .conversion-radio-ui {
    border-color: var(--primary);
}
.conversion-radio.is-active .conversion-radio-ui,
.conversion-radio input:checked + .conversion-radio-ui {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.conversion-radio.is-active .conversion-radio-dot,
.conversion-radio input:checked + .conversion-radio-ui .conversion-radio-dot {
    border-color: var(--primary);
}
.conversion-radio.is-active .conversion-radio-dot::after,
.conversion-radio input:checked + .conversion-radio-ui .conversion-radio-dot::after {
    background: var(--primary);
}
@media (max-width: 420px) {
    .conversion-radio-group { grid-template-columns: 1fr; }
}

.input-with-btn {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.input-with-btn select { flex: 1; }
.input-with-btn .ts-wrapper { flex: 1; min-width: 0; }
.input-with-btn .btn-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 22px;
    line-height: 1;
}

.input-prefix {
    position: relative;
}
.input-prefix .prefix {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}
.input-prefix input { padding-left: 48px; }

.calc-box {
    background: var(--calc-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 18px;
}
.calc-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 8px;
}
.calc-row:last-child { margin-bottom: 0; }
.calc-row span:first-child { color: var(--muted); }
.calc-row strong { font-weight: 700; }

/* Mobile cards */
.mobile-cards { display: none; }

.tx-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}
.tx-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.tx-card-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 12px;
}
.tx-card-meta .lbl { color: var(--muted); display: block; margin-bottom: 2px; }
.tx-card-meta .val { font-weight: 600; }
.tx-card-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.tx-card-actions .btn { width: 100%; }

.confirm-message {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 90;
}
.sidebar-backdrop.open { display: block; }

/* Quick-add modal (on top of drawer) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s;
    z-index: 300;
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal-card {
    position: fixed;
    top: 50%;
    left: 50%;
    width: min(420px, calc(100% - 32px));
    transform: translate(-50%, -46%) scale(0.98);
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    z-index: 310;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, transform .2s;
}
.modal-card.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Confirm dialog must sit above its own overlay */
#confirmOverlay {
    z-index: 320;
}
#confirmModal {
    z-index: 330;
    background: var(--card);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
}
.modal-footer .btn { flex: 1; }

/* ========== DAY SHEET ========== */
.kpi-sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.muted-text {
    font-size: 13px;
    color: var(--muted);
}

.field-error {
    margin-top: 6px;
    font-size: 12px;
    color: var(--danger);
}

.day-sheet-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.day-sheet-side {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.opening-form {
    padding: 18px 20px 20px;
}

.opening-hint {
    margin-top: 12px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--muted);
}

.cash-effect {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.summary-list {
    padding: 8px 20px 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--muted);
}

.summary-row strong { color: var(--text); font-weight: 700; }
.summary-row.total {
    border-bottom: none;
    padding-top: 14px;
    color: var(--text);
    font-size: 14px;
}

@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .day-sheet-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar {
        width: var(--sidebar-w);
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
    body.sidebar-collapsed .sidebar-brand span,
    body.sidebar-collapsed .nav-item .nav-label {
        opacity: 1;
        width: auto;
        overflow: visible;
        pointer-events: auto;
    }
    body.sidebar-collapsed .sidebar-brand { padding: 0 22px; justify-content: flex-start; }
    body.sidebar-collapsed .sidebar-nav { padding: 18px 14px; }
    body.sidebar-collapsed .nav-item {
        justify-content: flex-start;
        padding: 11px 14px;
        gap: 12px;
    }
    .main-wrap,
    body.sidebar-collapsed .main-wrap { margin-left: 0; }
    .topbar-search { display: none; }
    .content { padding: 18px; }
    .table-desktop { display: none; }
    .mobile-cards { display: block; padding: 14px; }
    .drawer { max-width: 100%; }
}

@media (max-width: 560px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 22px; }
}

/* ========== DAY BOOK ========== */
.daybook-card { padding: 0; overflow: hidden; }
.daybook-titlebar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 12px 16px;
    border-bottom: 1px dashed var(--border);
    background: var(--table-head);
}
.daybook-titlebar strong {
    font-size: 15px;
    margin-right: 10px;
}
.daybook-titlebar span { color: var(--muted); font-size: 13px; }
.daybook-logic-inline {
    font-size: 12px;
    color: var(--muted);
}

.daybook-spread-wrap { overflow-x: auto; }
.daybook-spread {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    table-layout: fixed;
    font-family: "Courier New", Courier, ui-monospace, monospace;
    font-size: 13px;
}
.daybook-spread th,
.daybook-spread td {
    border: 1px dashed var(--border);
    padding: 8px 10px;
    vertical-align: middle;
}
.daybook-spread thead th {
    background: var(--table-head);
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}
.daybook-spread .col-date { width: 11%; }
.daybook-spread .col-no { width: 18%; }
.daybook-spread .col-inr,
.daybook-spread .col-rate { width: 11%; }
.daybook-spread .col-pattu,
.daybook-spread .col-varavu,
.daybook-spread .col-bal { width: 12%; }
.daybook-spread .col-act { width: 13%; }
.daybook-spread .center { text-align: center; }
.daybook-spread .right { text-align: right; }
.daybook-spread .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.daybook-spread .strong { font-weight: 700; }
.daybook-spread .neg { color: #ef4444; }
.daybook-spread .opening-row td {
    background: rgba(37, 99, 235, 0.06);
    font-style: italic;
    color: var(--muted);
}
.daybook-spread tr.is-debit td.num { color: var(--text); }
.daybook-spread .empty-msg {
    text-align: center;
    padding: 28px 12px !important;
    color: var(--muted);
}
.daybook-spread tfoot td {
    background: var(--table-head);
    font-weight: 700;
}
.daybook-spread .act { padding: 6px !important; }
.daybook-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.daybook-actions .btn { padding: 0 8px; min-width: 0; height: 30px; font-size: 12px; }

.pay-row td { background: rgba(22, 163, 74, 0.06); }
.pay-remain { font-size: 12px; color: var(--muted); margin-right: 8px; }
.daybook-spread tr.is-credit td { background: rgba(22, 163, 74, 0.03); }
.edit-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
    gap: 10px;
    padding: 12px;
    align-items: end;
}
.edit-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
}
.edit-actions { display: flex; gap: 6px; align-items: end; padding-bottom: 1px; }

.daybook-add {
    border-top: 1px dashed var(--border);
    padding: 14px 16px 16px;
    background: rgba(37, 99, 235, 0.05);
}
.daybook-add-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}
.daybook-add-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 10px;
    align-items: end;
}
.daybook-add-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
}
.daybook-add-actions { display: flex; align-items: end; }
.daybook-add-preview {
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}
.daybook-add-preview strong { color: var(--text); }
.daybook-pay-hint {
    color: var(--primary);
    font-weight: 600;
}

.sheet-input {
    width: 100%;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text);
    padding: 0 8px;
    font-size: 13px;
}
.sheet-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.sheet-num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-status.is-unpaid { border-color: #f59e0b; color: #c2410c; }
.sheet-status.is-paid { border-color: #16a34a; color: #15803d; }
html[data-theme="dark"] .sheet-status.is-unpaid { color: #fdba74; }
html[data-theme="dark"] .sheet-status.is-paid { color: #86efac; }

@media (max-width: 900px) {
    .daybook-add-grid,
    .edit-grid { grid-template-columns: 1fr 1fr; }
}
