:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 14px;
    --shadow-sm: 0 1px 3px rgba(15,23,42,.06);
    --shadow-md: 0 4px 20px rgba(99,102,241,.12);
    --shadow-lg: 0 20px 50px rgba(99,102,241,.2);
    --gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- HEADER ---------- */
.topbar {
    background: var(--gradient);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    color: #fff;
    box-shadow: 0 8px 32px rgba(79,70,229,.25);
    position: sticky;
    top: 0;
    z-index: 100;
}
@keyframes gradientShift {
    0%,100% { background-position: 0% 50%; }
    50%     { background-position: 100% 50%; }
}
.topbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
    flex-shrink: 0;
}
.brand-icon {
    width: 42px; height: 42px;
    background: rgba(255,255,255,.18);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 1.3rem;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 1rem; letter-spacing: .2px; }
.brand-tag  { font-size: .68rem; opacity: .85; font-weight: 500; margin-top: 2px; }
.topbar nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}
.topbar nav a {
    color: rgba(255,255,255,.85);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 9px;
    font-size: .88rem;
    font-weight: 600;
    transition: all .2s;
}
.topbar nav a:hover {
    color: #fff;
    background: rgba(255,255,255,.15);
    transform: translateY(-1px);
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 4px 12px;
    background: rgba(255,255,255,.15);
    backdrop-filter: blur(10px);
    border-radius: 99px;
    margin-left: 10px;
}
.avatar {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, #fbbf24, #ec4899);
    border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 700; font-size: .8rem;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.user-name { font-size: .85rem; font-weight: 600; }
.logout {
    color: #fff !important;
    padding: 6px 12px !important;
    background: rgba(255,255,255,.22) !important;
    border-radius: 99px !important;
    font-size: .8rem !important;
    font-weight: 600 !important;
}
.logout:hover { background: rgba(255,255,255,.32) !important; }

.nav-toggle {
    display: none;
    background: rgba(255,255,255,.15);
    border: none;
    width: 42px; height: 42px;
    border-radius: 11px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
}
.nav-toggle span {
    display: block;
    width: 20px; height: 2px;
    background: #fff;
    border-radius: 2px;
}

/* ---------- CONTAINER ---------- */
.container {
    max-width: 1240px;
    margin: 24px auto;
    padding: 0 20px;
    animation: fadeIn .4s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- HEADINGS ---------- */
h1 {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -.5px;
    margin-bottom: 10px;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}
h2 { font-size: 1.4rem; margin: 16px 0 12px; }
h3 { font-size: 1.05rem; margin: 20px 0 12px; }

/* ---------- BUTTONS ---------- */
.btn, .btn-primary, .btn-sm, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 11px;
    text-decoration: none;
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: .88rem;
    font-weight: 600;
    font-family: inherit;
    transition: all .2s ease;
    box-shadow: var(--shadow-sm);
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary {
    background: var(--gradient);
    background-size: 200% 200%;
    color: #fff;
    border: none;
    box-shadow: 0 4px 14px rgba(99,102,241,.4);
}
.btn-primary:hover {
    animation: gradientShift 2s ease infinite;
    box-shadow: 0 8px 26px rgba(99,102,241,.55);
    transform: translateY(-2px);
}
.btn-sm { padding: 6px 12px; font-size: .78rem; border-radius: 9px; }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ---------- TABLES ---------- */
table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin: 8px 0 18px;
}
table.data thead th {
    background: linear-gradient(135deg, #f1f5f9, #e0e7ff);
    padding: 13px 14px;
    font-size: .74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    text-align: left;
}
table.data tbody td {
    padding: 13px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: .9rem;
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: #fafbff; }
.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-style: italic;
}

/* ---------- BADGES ---------- */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dcfce7; color: #166534; }

/* ---------- FLASH ---------- */
.flash {
    padding: 13px 16px;
    border-radius: 11px;
    margin-bottom: 18px;
    font-weight: 600;
    font-size: .9rem;
    border-left: 4px solid;
    animation: slideDown .4s ease;
}
.flash-success { background: #f0fdf4; color: #166534; border-color: var(--success); }
.flash-error   { background: #fef2f2; color: #991b1b; border-color: var(--danger); }
.flash-error ul { padding-left: 20px; }
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- FORMS ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}
label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
    letter-spacing: .2px;
}
input, select, textarea {
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font: inherit;
    font-size: .9rem;
    background: #fff;
    color: var(--text);
    transition: all .2s;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
label.full { width: 100%; margin-bottom: 14px; }

/* ---------- CARDS / TABS / ACTIONS ---------- */
.card {
    background: #fff;
    padding: 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}
.tabs {
    display: flex;
    gap: 8px;
    margin: 14px 0 18px;
    flex-wrap: wrap;
}
.tabs a {
    padding: 9px 18px;
    border-radius: 11px;
    background: #fff;
    border: 1.5px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 700;
    transition: all .2s;
    box-shadow: var(--shadow-sm);
}
.tabs a:hover { border-color: var(--primary); color: var(--primary); }
.tabs a.active {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(99,102,241,.4);
}
.actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- ITEMS TABLE (entry form) ---------- */
.items-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
    background: #fff;
}
.items { width: 100%; border-collapse: collapse; min-width: 560px; }
.items th {
    background: #f1f5f9;
    padding: 11px 10px;
    font-size: .74rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: .5px;
    color: var(--text-muted);
    text-align: left;
}
.items td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; }
.items tr:last-child td { border-bottom: none; }
.items select, .items input { width: 100%; }
.btn-remove {
    background: #fee2e2;
    border: none;
    color: var(--danger);
    border-radius: 8px;
    width: 32px; height: 32px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: all .2s;
}
.btn-remove:hover { background: var(--danger); color: #fff; }

/* ========== LOGIN PAGE ========== */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--gradient);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(255,255,255,.18) 0%, transparent 45%),
        radial-gradient(circle at 80% 80%, rgba(236,72,153,.35) 0%, transparent 45%);
    pointer-events: none;
}
.login-card {
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(20px);
    border-radius: 22px;
    padding: 40px 34px 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 30px 80px rgba(0,0,0,.3);
    position: relative;
    z-index: 1;
    animation: fadeIn .6s ease;
}
.login-card .logo {
    width: 64px; height: 64px;
    background: var(--gradient);
    border-radius: 18px;
    display: grid; place-items: center;
    font-size: 1.9rem; color: #fff;
    margin: 0 auto 18px;
    box-shadow: 0 10px 30px rgba(99,102,241,.4);
}
.login-card h2 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 4px;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.login-card .sub {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 26px;
    font-size: .88rem;
    font-weight: 500;
}

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 900px) {
    /* Table → Cards */
    table.data {
        background: transparent;
        box-shadow: none;
        margin-bottom: 12px;
    }
    table.data thead { display: none; }
    table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
    table.data tbody tr {
        background: #fff;
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 8px 16px;
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--border);
    }
    table.data tbody tr:hover td { background: transparent; }
    table.data tbody td {
        border: none;
        border-bottom: 1px dashed #f1f5f9;
        padding: 10px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        font-size: .9rem;
        text-align: right;
    }
    table.data tbody td:last-child { border-bottom: none; padding-bottom: 4px; }
    table.data tbody td::before {
        content: attr(data-label);
        font-weight: 800;
        color: var(--text-muted);
        font-size: .68rem;
        text-transform: uppercase;
        letter-spacing: .6px;
        flex-shrink: 0;
        text-align: left;
    }
    table.data tbody td:not([data-label])::before { content: none; }

    /* Nav */
    .topbar-inner { padding: 10px 16px; gap: 12px; }
    .brand-tag { display: none; }
    .brand-icon { width: 38px; height: 38px; font-size: 1.15rem; }
    .nav-toggle { display: flex; order: 3; margin-left: auto; }
    .topbar nav {
        position: fixed;
        top: 62px;
        left: 0; right: 0;
        background: linear-gradient(180deg, #4f46e5 0%, #7c3aed 60%, #6d28d9 100%);
        flex-direction: column;
        align-items: stretch;
        padding: 0 12px;
        gap: 4px;
        max-height: 0;
        overflow: hidden;
        transition: max-height .35s ease, padding .35s ease;
        margin-left: 0;
        box-shadow: 0 12px 30px rgba(0,0,0,.25);
        border-radius: 0 0 18px 18px;
    }
    body.nav-open .topbar nav { max-height: 500px; padding: 12px; }
    .topbar nav a { padding: 13px 16px; font-size: .95rem; border-radius: 10px; }
    .user-chip {
        margin: 10px 0 4px;
        padding: 8px 12px;
        justify-content: space-between;
        border-radius: 12px;
    }
    .user-chip .logout { margin-left: auto; }

    /* Layout */
    .container { margin: 18px auto; padding: 0 14px; }
    h1 { font-size: 1.55rem; }
    h2 { font-size: 1.2rem; }
    .grid { grid-template-columns: 1fr; gap: 10px; }
    .actions .btn, .actions .btn-primary { flex: 1; }
    .flash { font-size: .85rem; padding: 11px 14px; }
    .card { padding: 16px; }
    .login-card { padding: 32px 24px 26px; }
}

@media (max-width: 480px) {
    .brand-name { font-size: .92rem; }
    h1 { font-size: 1.4rem; }
    .tabs a { padding: 8px 14px; font-size: .82rem; }
    table.data tbody tr { padding: 6px 14px; }
    .user-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}