:root {
    --navy: #1a2332;
    --navy-soft: #243044;
    --navy-line: rgba(255, 255, 255, 0.08);
    --bg: #e8eef4;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5eaf0;
    --teal: #1aa87a;
    --teal-dark: #148a64;
    --blue: #4b8ed4;
    --blue-dark: #3b7ac0;
    --orange: #e39b22;
    --purple: #7b6cb8;
    --red: #e05656;
    --shadow: 0 8px 24px rgba(26, 35, 50, 0.06);
    --radius: 14px;
    --sidebar: 252px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

.flash {
    background: #e8f8f2;
    color: #0f6b4c;
    border: 1px solid #b7ebd4;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
}
.flash-error { background: #fdecec; color: #9b1c1c; border-color: #f5c2c2; }
.flash-warn {
    background: #fff6e0;
    color: #8a5a00;
    border: 1px solid #f0c36b;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 700;
    line-height: 1.7;
}
.field-error { color: var(--red); font-size: 12px; margin-top: 4px; }

/* ========== Public ========== */
.public-nav {
    background: var(--navy);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-color(180deg, #2d3d56, #1a2332);
    background: #2b3b54;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #f3c56b;
    border: 1px solid rgba(255,255,255,.12);
}
.brand h1 { margin: 0; font-size: 20px; font-weight: 800; }
.brand p { margin: 0; font-size: 12px; color: #9aa6b8; }
.nav-actions { display: flex; gap: 10px; align-items: center; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    cursor: pointer;
    border-radius: 999px;
    padding: 9px 16px;
    font-weight: 700;
    font-size: 14px;
    transition: .15s ease;
}
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-dark); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-dark); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost { background: transparent; color: #d5dde8; border: 1px solid rgba(255,255,255,.15); }
.btn-outline {
    background: #fff;
    color: var(--navy);
    border: 1px solid var(--line);
}
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-view {
    background: var(--teal);
    color: #fff;
    min-width: 78px;
    border-radius: 999px;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(26, 168, 122, 0.28);
}
.btn-view:hover { background: var(--teal-dark); }

.hero {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 20px 48px;
}
.hero-grid {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: 22px;
    align-items: start;
}
.hero-copy h2 {
    font-size: 34px;
    line-height: 1.35;
    margin: 8px 0 12px;
}
.hero-copy p { color: var(--muted); font-size: 16px; margin: 0 0 18px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--muted);
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,.7);
}
.card-pad { padding: 18px 20px; }
.card-title {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 800;
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.table-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.table-filters .input {
    width: 180px;
    background: #fff;
}

.calc-card { padding: 22px; }
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-grid .full, .result-grid .full { grid-column: 1 / -1; }
label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #374151;
}
.input, select, textarea {
    width: 100%;
    border: 1px solid #dbe3ec;
    background: #f8fafc;
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 14px;
    color: var(--text);
    outline: none;
}
.input:focus, select:focus, textarea:focus {
    border-color: #8bb7e6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(75, 142, 212, .15);
}
.plan-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.plan-pill {
    border: 1px solid #dbe3ec;
    background: #fff;
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
}
.plan-pill.active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}
.result {
    background: #f5f8fb;
    border-radius: 12px;
    padding: 10px 12px;
}
.result span { display: block; font-size: 12px; color: var(--muted); }
.result strong { font-size: 16px; }
.result.accent { background: #e9f8f2; }
.result.accent strong { color: var(--teal-dark); }
.result.warn { background: #fff6e8; }
.result.warn strong { color: #b7791f; }

.public-section { max-width: 1180px; margin: 0 auto 40px; padding: 0 20px; }

/* ========== Admin shell ========== */
.admin-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar);
    background: var(--navy);
    color: #fff;
    padding: 18px 14px;
    z-index: 20;
    overflow-y: auto;
}
.sidebar .brand { padding: 6px 8px 18px; border-bottom: 1px solid var(--navy-line); margin-bottom: 12px; }
.sidebar-brand {
    padding: 10px 8px 18px;
    border-bottom: 1px solid var(--navy-line);
    margin-bottom: 12px;
    text-align: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-brand h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.6;
    color: #fff;
}
.sidebar-close,
.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 12px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #2a3b55;
    color: #fff;
    padding: 0;
    flex: 0 0 42px;
}
.sidebar-close svg,
.menu-toggle svg { width: 20px; height: 20px; }
.sidebar-close {
    position: absolute;
    left: 0;
    top: 8px;
    background: transparent;
    border: 1px solid rgba(255,255,255,.16);
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 22, 32, 0.48);
    z-index: 19;
}
.login-title {
    text-align: center;
    color: var(--navy);
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 16px;
}
.login-card h2 { text-align: center; }
.menu { list-style: none; margin: 0; padding: 8px 0; }
.menu a, .menu summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 10px;
    color: #c9d3e0;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}
.menu svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }
.menu a:hover, .menu summary:hover { background: var(--navy-soft); color: #fff; }
.menu a.active {
    background: #2a3b55;
    color: #fff;
}
.menu details { margin: 2px 0; }
.menu details summary { list-style: none; }
.menu details summary::-webkit-details-marker { display: none; }
.menu .sub { padding: 0 8px 8px 8px; }
.menu .sub a { font-size: 13px; padding: 8px 12px; color: #9aa8bc; }
.chev { margin-right: auto; margin-left: 0; opacity: .5; }

.main {
    margin-right: var(--sidebar);
    min-height: 100vh;
    min-width: 0;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 18;
    background: var(--bg);
    padding: 16px 22px 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.search {
    flex: 1;
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 999px;
    padding: 0 16px;
    box-shadow: var(--shadow);
    height: 46px;
    border: 1px solid #edf1f5;
}
.search input {
    border: 0;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 14px;
}
.top-actions { display: flex; gap: 8px; }

.content { padding: 8px 22px 32px; }

.stats-row, .mini-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 8px 16px;
    text-align: center;
    min-height: 110px;
}
.stat-card .num {
    font-size: 34px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.5px;
}
.stat-card .lbl {
    color: var(--muted);
    font-size: 13px;
    margin-top: 8px;
    font-weight: 600;
}
.stat-card.green .num { color: var(--teal); }
.stat-card.blue .num { color: var(--blue); }
.stat-card.orange .num { color: var(--orange); }
.stat-card.purple .num { color: var(--purple); }
.mini-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mini-card .num { font-size: 26px; font-weight: 800; }
.num.blue { color: var(--blue); }
.pager nav { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.mini-card .lbl { color: var(--muted); font-size: 13px; font-weight: 700; }
.mini-card small { color: #9aa3af; font-size: 12px; }

.dash-mid {
    display: grid;
    grid-template-columns: .9fr 1.1fr;
    gap: 14px;
    margin-bottom: 14px;
}
.chart-wrap { height: 230px; display: grid; place-items: center; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: center; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 6px; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
    display: grid;
    grid-template-columns: 1.2fr .8fr auto;
    gap: 8px;
    padding: 10px 4px;
    border-bottom: 1px solid #f1f4f8;
    font-size: 13px;
    align-items: center;
}
.activity-list li:last-child { border-bottom: 0; }
.tag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
}
.tag-edit { background: #fff4df; color: #b7791f; }
.tag-login { background: #e8f8f2; color: #148a64; }
.tag-create { background: #e8f1fb; color: #2b6cb0; }
.tag-status { background: #eee8fa; color: #5b4aa3; }
.tag-delete { background: #fdecec; color: #9b1c1c; }
.muted { color: var(--muted); }
.time { color: #9aa3af; font-size: 12px; }

.dash-bottom {
    display: grid;
    grid-template-columns: 1.2fr 1fr .8fr;
    gap: 14px;
}
.list-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f4f8;
    font-size: 13px;
}
.list-row:last-child { border-bottom: 0; }

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
}
.badge-pending { background: #fff4df; color: #b7791f; }
.badge-approved { background: #e8f1fb; color: #2b6cb0; }
.badge-active { background: #e8f8f2; color: #148a64; }
.badge-completed { background: #eef1f4; color: #4b5563; }
.badge-rejected { background: #fdecec; color: #9b1c1c; }

.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data th, table.data td {
    padding: 12px 10px;
    border-bottom: 1px solid #f0f3f7;
    text-align: right;
    white-space: nowrap;
}
table.data th { color: var(--muted); font-weight: 700; font-size: 12px; }
table.data tr:hover td { background: #f8fafc; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pager a, .pager span {
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    font-size: 13px;
}
.pager .active { background: var(--navy); color: #fff; border-color: var(--navy); }

.details-grid {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 14px;
}
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f1f4f8; font-size: 14px; }
.kv b { color: var(--muted); font-weight: 600; }

.form-show {
    max-width: 860px;
    margin: 0 auto;
}
.btn-print {
    background: var(--navy);
    color: #fff;
    min-width: 110px;
    font-weight: 800;
    box-shadow: 0 6px 16px rgba(26, 35, 50, 0.18);
}
.btn-print:hover { background: #243044; }
.form-show-card { padding: 28px 28px 24px; }
.form-show-hero {
    text-align: center;
    padding: 8px 12px 22px;
    border-bottom: 1px solid #eef2f6;
    margin-bottom: 8px;
}
.form-show-hero h1 {
    margin: 12px 0 18px;
    font-size: 32px;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.4;
}
.form-show-amount span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}
.form-show-amount strong {
    display: block;
    font-size: 30px;
    font-weight: 800;
    color: var(--teal);
    letter-spacing: 0.2px;
}
.form-show-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 28px;
    padding: 8px 4px 4px;
}
.form-show-details .kv {
    grid-template-columns: 132px 1fr;
    align-items: center;
}
.form-show-details .kv span { font-weight: 700; color: var(--text); }
.form-show-details .kv-wide { grid-column: 1 / -1; }
.form-show-docs { margin-top: 18px; padding-top: 8px; }
.form-show-status {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid #eef2f6;
    text-align: center;
}
.form-show-status .card-title { margin-bottom: 14px; }
.status-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}
.status-actions .btn {
    min-width: 140px;
    font-weight: 800;
}
.btn-status-pending { background: #fff4df; color: #b7791f; }
.btn-status-pending:hover { background: #ffe7b5; }
.btn-status-approved { background: var(--teal); color: #fff; }
.btn-status-approved:hover { background: var(--teal-dark); }
.btn-status-rejected { background: var(--red); color: #fff; }
.btn-status-rejected:hover { background: #c94545; }
.status-actions .is-current {
    box-shadow: 0 0 0 3px rgba(26, 35, 50, 0.12);
    pointer-events: none;
    opacity: .92;
}
.form-show-more {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--navy);
    padding: 24px;
}
.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h2 { margin: 8px 0 4px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }

.print-sheet {
    max-width: 820px;
    margin: 24px auto;
    background: #fff;
    padding: 32px;
    border-radius: 12px;
}
.print-sheet h1 { text-align: center; margin: 0 0 6px; }
.print-meta { text-align: center; color: var(--muted); margin-bottom: 24px; }

.settings-help {
    background: #f5f8fb;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 13px;
    color: #4b5563;
    margin-bottom: 16px;
    line-height: 1.8;
}

@media (max-width: 1100px) {
    .stats-row, .mini-row { grid-template-columns: 1fr 1fr; }
    .dash-mid, .dash-bottom, .hero-grid, .details-grid { grid-template-columns: 1fr; }
    .form-grid, .result-grid, .upload-grid, .doc-thumbs, .form-show-details { grid-template-columns: 1fr; }
    .form-show-hero h1 { font-size: 26px; }
    .form-show-amount strong { font-size: 24px; }
    .form-show-card { padding: 20px 16px 18px; }
}
@media (max-width: 900px) {
    .menu-toggle { display: grid; }
    .sidebar-close { display: grid; }
    .sidebar {
        width: min(280px, 88vw);
        transform: translateX(110%);
        transition: transform .22s ease;
        padding-bottom: max(18px, env(safe-area-inset-bottom));
    }
    body.sidebar-open { overflow: hidden; }
    body.sidebar-open .sidebar { transform: translateX(0); box-shadow: -16px 0 40px rgba(0,0,0,.28); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .main { margin-right: 0; }
    .topbar {
        flex-wrap: wrap;
        padding: 12px 14px 8px;
        top: 0;
    }
    .search { min-width: 0; }
    .top-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    .top-actions .btn {
        flex: 1 1 calc(50% - 8px);
        font-size: 13px;
        padding: 9px 10px;
    }
    .desktop-only { display: none !important; }
    .content { padding: 8px 14px 28px; max-width: 100%; }
    .card { max-width: 100%; }
    .stat-card { min-height: 96px; padding: 14px 8px 12px; }
    .stat-card .num { font-size: 26px; }
    .stat-card .lbl { font-size: 12px; }
    .activity-list li { grid-template-columns: 1fr auto; }
    .table-filters { width: 100%; }
    .table-filters .input { width: 100%; flex: 1 1 140px; }
    .status-actions .btn { min-width: 0; flex: 1 1 140px; }
    .form-show { max-width: 100%; }
    .input, select, textarea, .search input { font-size: 16px; }
}
@media (max-width: 560px) {
    .stats-row, .mini-row { grid-template-columns: 1fr; }
    .public-nav { padding: 12px 14px; }
    .nav-actions .btn { padding: 8px 12px; font-size: 13px; }
}
.form-page {
    max-width: 920px;
    margin: 0 auto;
    padding: 28px 16px 48px;
}
.company-heading {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--navy);
    margin: 0 0 8px;
}
.form-heading {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 22px;
}
.form-actions {
    margin-top: 20px;
    text-align: center;
}
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 35, 50, 0.45);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 50;
}
.modal-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px 22px;
    text-align: center;
    box-shadow: var(--shadow);
}
.modal-card p {
    margin: 0 0 18px;
    font-size: 18px;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.7;
}
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.upload-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 160px;
    border: 2px dashed #d5dee8;
    border-radius: 14px;
    background: #f8fafc;
    padding: 16px 12px;
    cursor: pointer;
    text-align: center;
}
.upload-box:hover, .upload-box.has-file { border-color: #8bb7e6; background: #fff; }
.upload-box input[type="file"] { display: none; }
.upload-box img {
    max-height: 110px;
    max-width: 100%;
    border-radius: 8px;
    object-fit: cover;
}
.upload-title { font-weight: 800; font-size: 14px; }
.upload-hint { font-size: 12px; color: var(--muted); }
.doc-thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.doc-thumbs img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }

.upload-box.has-file .upload-hint { display: none; }

@media print {
    .no-print { display: none !important; }
    .print-sheet { box-shadow: none; margin: 0; }
}
