/* ==========================================================================
   ATSMS - Premium application stylesheet
   theme-light -> public site (landing, static, login)
   theme-dark  -> admin shell + project portal (sidebar layout)
   ========================================================================== */

/* 1. Design tokens --------------------------------------------------------- */
:root {
    --font: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    --indigo-500: #6366f1; --indigo-600: #4f46e5; --indigo-700: #4338ca;
    --violet-500: #8b5cf6; --violet-600: #7c3aed;
    --cyan-500: #06b6d4;  --cyan-400: #22d3ee;
    --green-500: #10b981; --green-600: #059669;
    --amber-500: #f59e0b; --amber-600: #d97706;
    --red-500: #ef4444;   --red-600: #dc2626;
    --slate-50: #f8fafc;  --slate-100: #f1f5f9; --slate-200: #e2e8f0;
    --slate-300: #cbd5e1; --slate-400: #94a3b8; --slate-500: #64748b;
    --slate-600: #475569; --slate-700: #334155; --slate-800: #1e293b;
    --slate-900: #0f172a; --slate-950: #020617;
    --grad-brand: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #06b6d4 130%);
    --grad-brand-soft: linear-gradient(135deg, rgba(99,102,241,.12), rgba(139,92,246,.12));
    --radius-sm: 8px; --radius: 14px; --radius-lg: 20px;
    --ring: 0 0 0 3px rgba(99,102,241,.25);
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
    --shadow-md: 0 4px 12px -2px rgba(15,23,42,.10), 0 2px 4px rgba(15,23,42,.06);
    --shadow-lg: 0 18px 40px -12px rgba(15,23,42,.22), 0 6px 14px -6px rgba(15,23,42,.12);
    --shadow-brand: 0 8px 20px -6px rgba(79,70,229,.45);
    --ease: cubic-bezier(.4,0,.2,1);
}

body.theme-dark {
    --bg: var(--slate-950); --bg-alt: var(--slate-900);
    --surface: var(--slate-800); --surface-2: rgba(255,255,255,.04);
    --border: rgba(148,163,184,.14); --border-strong: rgba(148,163,184,.28);
    --text: #cbd5e1; --text-strong: #f8fafc; --text-muted: var(--slate-400);
    --shadow-panel: 0 16px 36px -14px rgba(2,6,23,.65);
    --row-hover: rgba(99,102,241,.08); --input-bg: rgba(2,6,23,.45);
    color-scheme: dark;
}

body.theme-light {
    --bg: var(--slate-50); --bg-alt: #ffffff;
    --surface: #ffffff; --surface-2: var(--slate-50);
    --border: var(--slate-200); --border-strong: var(--slate-300);
    --text: #334155; --text-strong: var(--slate-900); --text-muted: var(--slate-500);
    --shadow-panel: var(--shadow-md);
    --row-hover: rgba(99,102,241,.05); --input-bg: #ffffff;
    color-scheme: light;
}

/* 2. Base / reset ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16.5px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    background: var(--bg);
    color: var(--text);
    transition: background .3s var(--ease), color .3s var(--ease);
}

h1, h2, h3, h4 {
    margin: 0 0 .5em;
    color: var(--text-strong);
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.25;
}

p { margin: 0 0 1em; }
a { color: var(--indigo-500); text-decoration: none; transition: color .2s var(--ease); }
a:hover { color: var(--indigo-600); }
img { max-width: 100%; display: block; }
::selection { background: rgba(99,102,241,.35); color: #fff; }
:focus-visible { outline: 2px solid var(--indigo-500); outline-offset: 2px; border-radius: 4px; }

.mt-2 { margin-top: 12px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.lead { font-size: 18px; color: var(--text-muted); max-width: 62ch; }

.section-title {
    font-size: 26px;
    margin: 44px 0 18px;
    position: relative;
    padding-left: 16px;
}
.section-title::before {
    content: '';
    position: absolute;
    left: 0; top: 6px; bottom: 8px;
    width: 4px;
    border-radius: 4px;
    background: var(--grad-brand);
}

/* 3. Buttons ---------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: 1px solid transparent;
    border-radius: 10px;
    font: 600 15px/1.2 var(--font);
    letter-spacing: .01em;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all .2s var(--ease);
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(.99); }

.btn-primary {
    background: var(--grad-brand);
    color: #fff !important;
    box-shadow: var(--shadow-brand);
}
.btn-primary:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 12px 26px -8px rgba(79,70,229,.55);
}

.btn-ghost {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-strong) !important;
}
.btn-ghost:hover {
    border-color: var(--indigo-500);
    color: var(--indigo-500) !important;
    background: var(--grad-brand-soft);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--red-500), var(--red-600));
    color: #fff !important;
    box-shadow: 0 6px 16px -6px rgba(220,38,38,.45);
}
.btn-danger:hover { filter: brightness(1.08); transform: translateY(-1px); }

.btn-success {
    background: linear-gradient(135deg, var(--green-500), var(--green-600));
    color: #fff !important;
    box-shadow: 0 6px 16px -6px rgba(5,150,105,.45);
}
.btn-success:hover { filter: brightness(1.08); transform: translateY(-1px); }

.btn-sm { padding: 8px 15px; font-size: 14px; border-radius: 8px; }
.btn-block { width: 100%; }
.inline-form { display: inline-block; margin: 0; }

/* 3b. Data tables -------------------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table.data {
    width: 100%;
    border-collapse: collapse;
}
table.data td.actions { white-space: nowrap; }

/* 4. Badges & alerts --------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .02em;
    border: 1px solid transparent;
    line-height: 1.5;
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
}
.badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .7;
}
.badge-success { background: rgba(16,185,129,.12); color: var(--green-500); border-color: rgba(16,185,129,.3); }
.badge-warning { background: rgba(245,158,11,.14); color: var(--amber-500); border-color: rgba(245,158,11,.35); }
.badge-danger  { background: rgba(239,68,68,.12);  color: var(--red-500);  border-color: rgba(239,68,68,.3); }
.badge-info    { background: rgba(6,182,212,.12);  color: var(--cyan-400); border-color: rgba(6,182,212,.3); }
.badge-muted   { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
body.theme-light .badge-info { color: #0891b2; }
body.theme-light .badge-success { color: var(--green-600); }
body.theme-light .badge-warning { color: var(--amber-600); }
body.theme-light .badge-danger { color: var(--red-600); }

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 18px;
    margin: 0 0 18px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    font-size: 15px;
    animation: slideDown .35s var(--ease);
}
.alert::before { font-size: 16px; line-height: 1.4; }
.alert-success { background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.35); color: var(--green-500); }
.alert-success::before { content: '\2713'; }
.alert-error { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.35); color: var(--red-500); }
.alert-error::before { content: '\2717'; }
.alert-info { background: rgba(6,182,212,.1); border-color: rgba(6,182,212,.35); color: var(--cyan-400); }
.alert-info::before { content: '\2139'; }
.alert-warning { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.35); color: var(--amber-500); }
.alert-warning::before { content: '\26A0'; }
body.theme-light .alert-success { color: var(--green-600); }
body.theme-light .alert-error { color: var(--red-600); }
body.theme-light .alert-info { color: #0891b2; }
body.theme-light .alert-warning { color: var(--amber-600); }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 5. Public site: header ---------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.site-header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    font-weight: 800;
    font-size: 19px;
    letter-spacing: -0.02em;
    color: var(--slate-900) !important;
}
.brand img { height: 34px; width: auto; }

.site-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.site-nav > a:not(.btn) {
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--slate-600);
    font-weight: 500;
    font-size: 14px;
    transition: all .2s var(--ease);
}
.site-nav > a:not(.btn):hover {
    color: var(--indigo-600);
    background: var(--grad-brand-soft);
}

/* 6. Landing: hero ----------------------------------------------------------- */
.site-body {
    max-width: 1120px;
    margin: 0 auto;
    padding: 8px 24px 40px;
}

.hero {
    position: relative;
    overflow: hidden;
    margin-top: 24px;
    padding: 64px 48px 56px;
    background:
        radial-gradient(ellipse 60% 90% at 8% 0%, rgba(99, 102, 241, 0.22), transparent 60%),
        radial-gradient(ellipse 50% 80% at 95% 10%, rgba(6, 182, 212, 0.16), transparent 60%),
        radial-gradient(ellipse 55% 70% at 55% 110%, rgba(139, 92, 246, 0.14), transparent 60%),
        linear-gradient(180deg, #ffffff 0%, var(--slate-50) 100%);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.055) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(180deg, #000 40%, transparent 90%);
    -webkit-mask-image: linear-gradient(180deg, #000 40%, transparent 90%);
    pointer-events: none;
}

.hero h1 {
    position: relative;
    max-width: 38ch;
    margin: 0 auto 18px;
    font-size: clamp(28px, 3.6vw, 40px);
    text-wrap: balance;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(120deg, #0f172a 30%, #4f46e5 75%, #7c3aed 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero .lead { margin: 0 auto 30px; text-align: center; font-size: 19px; }

.hero-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    margin-bottom: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--indigo-600);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.hero-pill::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--green-500);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
    50% { box-shadow: 0 0 0 6px rgba(16,185,129,.08); }
}

.hero-actions {
    position: relative;
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* 7. Landing: slider, features, stats ---------------------------------------- */
.slider-card {
    margin-top: 30px;
    padding: 26px 30px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-panel);
}
.slider-card h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--slate-500);
    margin-bottom: 14px;
}
.slider-card h2::before {
    content: '\25C8';
    color: var(--indigo-500);
    font-size: 17px;
}

.slider-slide {
    display: none;
    padding: 16px 22px;
    border-radius: var(--radius-sm);
    background: var(--grad-brand-soft);
    border-left: 3px solid var(--indigo-500);
    font-size: 17px;
    color: var(--slate-700);
    font-weight: 500;
}
.slider-slide.active {
    display: block;
    animation: slideDown .5s var(--ease);
}
.slider-meta {
    display: block;
    margin-top: 7px;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--indigo-600);
    opacity: .85;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

.card {
    position: relative;
    overflow: hidden;
    padding: 26px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--grad-brand);
    opacity: 0;
    transition: opacity .25s var(--ease);
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(99, 102, 241, 0.35);
}
.card:hover::before { opacity: 1; }
.card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    margin-bottom: 8px;
}
.card p { margin: 0; color: var(--text-muted); font-size: 15.5px; }

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 26px 24px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
    transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card::after {
    content: '';
    position: absolute;
    right: -22px; top: -22px;
    width: 84px; height: 84px;
    border-radius: 50%;
    background: var(--grad-brand-soft);
    opacity: .9;
}
.stat-value {
    position: relative;
    z-index: 1;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-variant-numeric: tabular-nums;
}
.stat-label {
    position: relative;
    z-index: 1;
    margin-top: 4px;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; }

/* 8. Public footer ------------------------------------------------------------ */
.site-footer {
    margin-top: 70px;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, var(--slate-900), var(--slate-950));
    color: var(--slate-400);
}
.site-footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 44px 24px 30px;
    display: grid;
    grid-template-columns: 1.4fr 2fr;
    gap: 30px;
}
.footer-about strong {
    display: block;
    font-size: 17px;
    color: #f8fafc;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
}
.footer-about p { margin: 0; font-size: 15px; }
.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 22px;
    align-content: center;
}
.footer-links a { color: var(--slate-400); font-size: 15px; transition: color .2s var(--ease); }
.footer-links a:hover { color: var(--cyan-400); }
.footer-copy {
    grid-column: 1 / -1;
    margin: 6px 0 0;
    padding-top: 22px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    font-size: 14px;
    color: var(--slate-500);
}

/* 9. Admin shell: layout ------------------------------------------------------ */
.app-shell {
    display: grid;
    grid-template-columns: 264px 1fr;
    min-height: 100vh;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background:
        radial-gradient(ellipse 55% 45% at 100% 0%, rgba(99, 102, 241, 0.07), transparent 60%),
        radial-gradient(ellipse 40% 35% at 0% 100%, rgba(6, 182, 212, 0.05), transparent 60%),
        var(--bg);
}

.app-content {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 26px 30px 50px;
}

/* 10. Sidebar ------------------------------------------------------------------ */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--slate-900) 0%, var(--slate-950) 100%);
    border-right: 1px solid rgba(148, 163, 184, 0.1);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 22px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
.sidebar-header > span {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: #f8fafc;
}
.sidebar-logo img { height: 34px; width: auto; }

.sidebar-nav {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--slate-400) !important;
    font-size: 15px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all .2s var(--ease);
}
.nav-item:hover {
    color: #e2e8f0 !important;
    background: rgba(148, 163, 184, 0.08);
}

.nav-item.active {
    color: #ffffff !important;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.9), rgba(124, 58, 237, 0.85));
    box-shadow: 0 6px 16px -6px rgba(79, 70, 229, 0.5);
    font-weight: 600;
}
.nav-item.active::before {
    content: '';
    width: 3px;
    height: 18px;
    margin-left: -8px;
    border-radius: 3px;
    background: #ffffff;
    opacity: .9;
}
.nav-item .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 16px 18px;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.06);
}
.user-avatar {
    width: 36px; height: 36px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--grad-brand);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    box-shadow: var(--shadow-brand);
}
.user-details { min-width: 0; }
.user-name {
    display: block;
    font-size: 14.5px;
    font-weight: 600;
    color: #e2e8f0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-email {
    display: block;
    font-size: 12.5px;
    color: var(--slate-500);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.logout-btn {
    display: block;
    margin-top: 10px;
    padding: 8px 12px;
    text-align: center;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    color: var(--slate-400) !important;
    font-size: 14px;
    font-weight: 600;
    transition: all .2s var(--ease);
}
.logout-btn:hover {
    color: var(--red-500) !important;
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
}

/* 11. Topbar -------------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 15px 30px;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(12px) saturate(1.3);
    -webkit-backdrop-filter: blur(12px) saturate(1.3);
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
.topbar-title {
    margin: 0;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.topbar-sub {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--indigo-500);
    font-size: 13px;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-user {
    padding: 6px 13px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.28);
    color: var(--cyan-400);
    font-size: 13.5px;
    font-weight: 600;
}

/* 12. Panels & cards (admin) ------------------------------------------------------ */
.panel {
    margin-bottom: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
    overflow: hidden;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    flex-wrap: nowrap;
}

.panel-title-group {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
}

.view-toggle {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    flex-shrink: 1;
    min-width: 0;
}

.filter-form input[type="search"] {
    width: auto;
    min-width: 180px;
    max-width: 260px;
    flex: 1 1 auto;
}

.filter-form .field { margin: 0; min-width: 130px; }

/* Revenue collection-period filter: labelled fields that wrap cleanly, with
   the Apply/Reset buttons kept together and aligned to the bottom of the row. */
.revenue-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
}
.revenue-filters .field { margin: 0; flex: 1 1 190px; min-width: 160px; }
.revenue-filters input[type="search"] { width: 100%; }
.revenue-filters-actions {
    display: flex;
    gap: 10px;
    flex: 0 0 auto;
    align-items: flex-end;
}
.panel-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Add-payment popup (shared by revenue + project detail). */
.payment-dialog {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px 26px;
    width: min(720px, 94vw);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.payment-dialog::backdrop { background: rgba(2, 6, 23, .7); }
.payment-dialog h3 { margin: 0 0 6px; font-size: 20px; color: var(--text-strong); }
.payment-dialog .form-actions { margin-top: 18px; padding-top: 16px; justify-content: flex-end; }

/* 14. Forms ---------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--text-strong);
}
.required { color: var(--red-500); }

input[type='text'], input[type='email'], input[type='password'],
input[type='number'], input[type='date'], input[type='datetime-local'],
input[type='tel'], input[type='url'], select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--input-bg);
    color: var(--text-strong);
    font: 500 15px/1.5 var(--font);
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
textarea { min-height: 96px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--indigo-500);
    box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .8; }

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 36px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 18px;
}
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}
.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 13.5px;
    color: var(--text-muted);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 4px;
}
.checkbox-row input[type='checkbox'] {
    width: 17px; height: 17px;
    accent-color: var(--indigo-600);
    cursor: pointer;
}
.checkbox-row label { margin: 0; font-weight: 500; font-size: 14.5px; cursor: pointer; }

/* 15. Key-value list (detail panels) ---------------------------------------- */
.kv-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
}
.kv-item {
    padding: 13px 16px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.kv-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 3px;
    font-size: 12px;
}
.kv-value {
    display: block;
    font-size: 15.5px;
    font-weight: 600;
    color: var(--text-strong);
    word-break: break-word;
}
/* Revenue "Current balances" holds money figures — keep each amount on one
   line so numbers never break mid-value. */
.revenue-page .kv-value {
    word-break: normal;
    overflow-wrap: normal;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* 16. Portal & tickets -------------------------------------------------------- */
.portal-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.portal-nav a {
    padding: 9px 18px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-strong) !important;
    font-weight: 600;
    font-size: 13.5px;
    transition: all .2s var(--ease);
}
.portal-nav a:hover {
    border-color: var(--indigo-500);
    background: var(--grad-brand-soft);
    transform: translateY(-1px);
}
.portal-project {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.portal-links { display: flex; gap: 10px; flex-wrap: wrap; }

.ticket-body {
    padding: 16px 20px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--indigo-500);
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}
.ticket-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    color: var(--text-muted);
    font-size: 14px;
}
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 18px;
    font-weight: 600;
    font-size: 14.5px;
    color: var(--text-muted) !important;
}
.back-link::before { content: '\2190'; }
.back-link:hover { color: var(--indigo-500) !important; }

/* 16b. Inline page modal ------------------------------------------------------- */
.page-modal {
    border: none;
    border-radius: var(--radius);
    width: min(1100px, 96vw);
    height: min(720px, 86vh);
    max-width: 96vw;
    max-height: 86vh;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.page-modal::backdrop {
    background: rgba(2, 6, 23, .7);
}
.page-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.page-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-strong);
}
.page-modal-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .2s, color .2s;
}
.page-modal-close:hover {
    background: var(--row-hover);
    color: var(--text-strong);
}
.page-modal-body {
    position: relative;
    width: 100%;
    height: calc(100% - 56px);
    overflow: hidden;
}
.page-modal-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--surface-2);
}

/* Tabbed views on the projects page (Projects table + linked pages). */
.project-tabs-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}
.project-tab {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.project-tab:hover {
    background: var(--row-hover);
    color: var(--text-strong);
}
.project-tab[aria-selected="true"] {
    background: var(--surface);
    color: var(--indigo-500);
    border-color: var(--indigo-500);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.project-tabs {
    padding: 0;
    overflow: hidden;
}
/* Projects table: full grid (row + column borders) for a crisp boxed look. */
[data-tab-view="projects"] table.data th,
[data-tab-view="projects"] table.data td {
    border: 1px solid var(--border);
}
.project-tabs-body {
    position: relative;
    width: 100%;
    height: min(680px, 76vh);
}
.project-tabs-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--surface-2);
}
.project-tabs.loading .project-tabs-body::after {
    content: "Loading...";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: var(--surface-2);
}

/* 17. Auth & static pages -------------------------------------------------------- */
.auth-wrap {
    max-width: 430px;
    margin: 60px auto 40px;
    padding: 38px 36px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.auth-wrap::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--grad-brand);
}
.auth-wrap h1 { font-size: 24px; margin-bottom: 6px; }
.auth-wrap .lead { font-size: 15.5px; margin-bottom: 24px; }
.auth-hint {
    margin: 18px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

.static-container { max-width: 820px; margin: 0 auto; }
.section-card {
    padding: 30px 34px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
    margin-bottom: 22px;
}
.section-card h2 {
    font-size: 20px;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.section-list { padding-left: 20px; }
.section-list li { margin-bottom: 8px; }

/* Readable public typography; keep the dark portal's scale independent. */
body.theme-light { font-size: 17px; }
.theme-light .site-nav > a:not(.btn),
.theme-light .btn,
.theme-light .card p,
.theme-light .footer-about p,
.theme-light .footer-links a { font-size: 16px; }
.theme-light .btn-sm { font-size: 15px; }
.theme-light .hero .lead { font-size: 19px; }
.theme-light .field label,
.theme-light .checkbox-row label { font-size: 15px; }
.theme-light input:not([type='checkbox']):not([type='radio']):not([type='hidden']),
.theme-light select,
.theme-light textarea { font-size: 16px; line-height: 1.5; }
.theme-light .slider-meta,
.theme-light .stat-label,
.theme-light .badge,
.theme-light .field-help { font-size: 14px; }
.theme-light .site-header-inner { flex-wrap: wrap; gap: 12px; }
.theme-light .site-nav { flex-wrap: wrap; }


/* 18. Responsive ----------------------------------------------------------------- */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .app-shell { grid-template-columns: 232px 1fr; }
}

@media (max-width: 820px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 4px;
        padding: 10px 14px;
        border-right: none;
        border-bottom: 1px solid rgba(148,163,184,.1);
    }
    .sidebar-header { padding: 6px 10px; border-bottom: none; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; padding: 4px 0; overflow-x: auto; }
    .nav-item { padding: 8px 12px; }
    .nav-item.active::before { display: none; }
    .sidebar-footer { display: none; }
    .topbar { padding: 12px 18px; }
    .app-content { padding: 20px 16px 40px; }
    .grid-2, .grid-4, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .hero { padding: 46px 24px 42px; margin-top: 22px; }
    .hero .lead { font-size: 16.5px; }
    .hero-actions .btn { width: 100%; }
    .site-header-inner { padding: 12px 16px; }
    .site-nav > a:not(.btn) { padding: 7px 9px; font-size: 14px; }
    .site-footer-inner { grid-template-columns: 1fr; gap: 18px; padding: 34px 20px 24px; }
    .stat-value { font-size: 30px; }
    .section-title { font-size: 22px; }
    .auth-wrap { margin: 26px 14px; padding: 28px 22px; }
    .section-card { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}


/* 19. Landing redesign: services, process, highlights, CTA -------------------- */
.hero-ticks {
    position: relative;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 26px;
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px dashed rgba(99, 102, 241, 0.25);
}
.hero-ticks span {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--slate-600);
}

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

.service-card { padding: 30px 28px; }
.service-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
    border-radius: 14px;
    font-size: 26px;
    background: var(--grad-brand-soft);
    border: 1px solid rgba(99, 102, 241, 0.22);
}
.service-card h3 { margin-bottom: 6px; }

.process-track {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    counter-reset: none;
}
.process-step {
    position: relative;
    padding: 26px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.process-step:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(99, 102, 241, 0.35);
}
.process-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-bottom: 14px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: .02em;
    color: #fff;
    background: var(--grad-brand);
    box-shadow: var(--shadow-brand);
}
.process-step h3 { font-size: 17px; margin-bottom: 6px; }
.process-step p { margin: 0; font-size: 14.5px; color: var(--text-muted); }

.cta-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 34px;
    padding: 38px 42px;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(ellipse 70% 120% at 100% 0%, rgba(6, 182, 212, 0.25), transparent 60%),
        radial-gradient(ellipse 60% 110% at 0% 100%, rgba(139, 92, 246, 0.28), transparent 55%),
        var(--grad-brand);
    color: #fff;
    box-shadow: var(--shadow-brand);
}
.cta-band h2 {
    margin: 0 0 6px;
    font-size: 24px;
    color: #fff;
}
.cta-band p { margin: 0; opacity: .92; font-size: 16px; }
.cta-band .btn-primary {
    background: #fff;
    color: var(--indigo-600);
    box-shadow: 0 6px 18px rgba(2, 6, 23, .25);
}
.cta-band .btn-primary:hover { color: var(--indigo-700); transform: translateY(-2px); }

.btn-lg { padding: 13px 30px; font-size: 16.5px; }

@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .process-track { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
    .grid-3, .process-track { grid-template-columns: 1fr; }
    .cta-band { padding: 30px 24px; }
    .cta-band .btn-primary { width: 100%; }
    .hero-ticks { flex-direction: column; gap: 8px; }
}
