@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --sidebar-w: 17.5rem;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, 0.08);
    --accent: #0d9488;
    --accent-soft: rgba(13, 148, 136, 0.12);
    --bg: #eef2f7;
    --bg-subtle: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #64748b;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --success: #059669;
    --success-soft: #ecfdf5;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --cash: #059669;
    --card-color: #2563eb;
    --online: #7c3aed;
    --summary: #ea580c;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 0.9375rem;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

.icon-svg { flex-shrink: 0; display: block; }

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

.app-main-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(ellipse 80% 50% at 100% 0%, rgba(37, 99, 235, 0.04) 0%, transparent 50%),
        var(--bg);
}

.app-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-xs);
}

.header-title h1 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.breadcrumb {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.header-branch-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    background: var(--primary-soft);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.75rem 0.35rem 0.35rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.header-user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.header-user-meta strong { font-size: 0.8125rem; font-weight: 600; }
.header-user-meta small { font-size: 0.6875rem; color: var(--muted); }

.app-main {
    padding: 1.5rem;
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text);
    transition: all var(--transition);
}

.sidebar-toggle:hover { background: var(--bg-subtle); border-color: var(--primary); color: var(--primary); }

/* ─── Sidebar brand override ─── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0.5rem 1.25rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand img {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.sidebar-brand strong { display: block; font-size: 0.9375rem; color: #fff; letter-spacing: -0.01em; }
.sidebar-brand small { color: #94a3b8; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; }

.sidebar-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
}

.sidebar-link.is-active .sidebar-icon,
.sidebar-link:hover .sidebar-icon {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 0.75rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
}

.sidebar-footer-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d9488, #2563eb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-footer strong { color: #fff; font-size: 0.8125rem; display: block; }
.sidebar-footer small { color: #94a3b8; font-size: 0.6875rem; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
}

/* ─── Cards ─── */
.card, .premium-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 1.25rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.card:hover, .premium-card:hover { box-shadow: var(--shadow-md); }

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.card-header h2, .card-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

.card-body { padding: 1.25rem; }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.btn-outline {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
    text-decoration: none;
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.btn-danger:hover { color: #fff; text-decoration: none; transform: translateY(-1px); }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}

.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 0.9375rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0.5rem; width: 38px; height: 38px; }

/* ─── Forms ─── */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:hover, .form-select:hover { border-color: #cbd5e1; }

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-input.computed-field {
    background: linear-gradient(180deg, #f0fdf4 0%, #ecfdf5 100%);
    border-color: #bbf7d0;
    font-weight: 700;
    color: #166534;
}

.form-input.diff, .text-diff { color: var(--danger) !important; font-weight: 700; }

.header-select {
    min-width: 160px;
    padding: 0.45rem 2rem 0.45rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    background: var(--surface) 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='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.65rem center;
    appearance: none;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.full-width { grid-column: 1 / -1; }

/* ─── Alerts ─── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.alert-error { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }

/* ─── Tables ─── */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

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

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: rgba(37, 99, 235, 0.02); }

.data-table tbody tr:last-child td { border-bottom: none; }

.total-row { background: var(--bg-subtle) !important; font-weight: 600; }
.total-row td { color: var(--text) !important; }

.table-responsive, .table-scroll { overflow-x: auto; border-radius: var(--radius-md); }

/* ─── Status badges ─── */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-draft { background: #f1f5f9; color: #475569; }
.status-submitted { background: #dbeafe; color: #1d4ed8; }
.status-verified { background: #ede9fe; color: #6d28d9; }
.status-approved { background: #d1fae5; color: #047857; }
.status-rejected { background: #fee2e2; color: #b91c1c; }

/* ─── Page toolbar ─── */
.page-toolbar, .dashboard-filters {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 0.85rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
}

.inline-form { display: flex; gap: 0.65rem; align-items: center; flex-wrap: wrap; }
.inline-form label { font-size: 0.8125rem; font-weight: 600; color: var(--muted); margin: 0; }

.page-section-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin: 0 0 0.75rem;
}

.report-list { margin: 0; padding: 0; list-style: none; }
.report-list li {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.report-list li:last-child { border-bottom: none; }
.report-list li::before { content: '→ '; color: var(--primary); font-weight: 600; }

.report-export-form { max-width: 480px; }

/* ─── Login page ─── */
.login-page { min-height: 100vh; background: var(--bg); }

.login-shell {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    min-height: 100vh;
}

.login-aside {
    position: relative;
    background: linear-gradient(160deg, #0b1e3b 0%, #0f2744 40%, #0a1628 100%);
    color: #fff;
    padding: 3.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.login-aside::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 20% 20%, rgba(13, 148, 136, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse 50% 40% at 80% 80%, rgba(37, 99, 235, 0.15) 0%, transparent 50%);
    pointer-events: none;
}

.login-aside-inner { position: relative; z-index: 1; max-width: 420px; }

.login-aside-logo {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.login-aside-kicker {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #2dd4bf;
    margin: 0 0 0.5rem;
}

.login-aside h2 {
    margin: 0 0 1rem;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.login-aside-text {
    font-size: 1rem;
    line-height: 1.7;
    color: #94a3b8;
    margin: 0 0 2rem;
}

.login-features { list-style: none; padding: 0; margin: 0; }

.login-features li {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: #cbd5e1;
}

.login-features li::before {
    content: '✓';
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 148, 136, 0.2);
    color: #2dd4bf;
    border-radius: 50%;
    font-size: 0.6875rem;
    font-weight: 700;
}

.login-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(37, 99, 235, 0.05) 0%, transparent 60%),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    padding: 2.25rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-card h1 {
    margin: 0 0 0.35rem;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.login-lede {
    color: var(--muted);
    font-size: 0.875rem;
    margin: 0 0 1.75rem;
}

.login-form .form-group { margin-bottom: 1.15rem; }

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    background: var(--bg-subtle);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

/* ─── Premium page extras ─── */
.card-header h2, .card-header h3 {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.header-meta-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.tracker-form-card { margin-top: 0.5rem; }
.tracker-form-inline { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-light); }

.form-actions-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
}

.code-pill {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8125rem;
    font-family: ui-monospace, monospace;
    color: var(--text-secondary);
}

.status-pending { background: var(--warning-soft); color: var(--warning); }
.status-sent { background: #dbeafe; color: #1d4ed8; }
.status-report_received { background: #ede9fe; color: #6d28d9; }
.status-shared_with_owner { background: var(--success-soft); color: var(--success); }

.page-toolbar .icon-svg,
.dashboard-filters .icon-svg,
.inline-form .icon-svg { color: var(--muted); }

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.mis-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-daily-mis .mis-card-header {
    display: block;
}
