:root {
    --ink: #1c1712;
    --emerald: #0c3d32;
    --emerald-deep: #041910;
    --gold: #d4af37;
    --gold-soft: #f0d78c;
    --cream: #f6f0e4;
    --parchment: #fffaf2;
    --line: rgba(212, 175, 55, 0.45);
    --danger: #8a3030;
    --ok: #14624d;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    --sans: "Outfit", "Segoe UI", sans-serif;
    --display: "Cormorant Garamond", Palatino, Georgia, serif;
    --urdu: "Jameel Noori Nastaleeq", "Segoe UI", serif;
    --arabic: var(--urdu);
}

@font-face {
    font-family: "Jameel Noori Nastaleeq";
    src: url("../font/Jameel Noori Nastaleeq Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--sans), var(--urdu);
    color: var(--ink);
}

button, input, select { font: inherit; }

a { color: inherit; }

.login-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 20% 10%, rgba(212, 175, 55, 0.16), transparent 32%),
        radial-gradient(circle at 80% 80%, rgba(20, 92, 73, 0.45), transparent 36%),
        linear-gradient(165deg, #03140f 0%, #0b3a2e 48%, #06261f 100%);
    overflow-x: hidden;
    overflow-y: auto;
}

.scene {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.geo-pattern {
    position: absolute;
    width: 140%;
    height: 140%;
    left: -20%;
    top: -20%;
    opacity: 0.28;
    animation: drift 36s linear infinite;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(30px);
    animation: pulse-glow 7s ease-in-out infinite;
}

.glow-gold {
    width: 340px;
    height: 340px;
    top: -80px;
    left: -40px;
    background: rgba(240, 215, 140, 0.28);
}

.glow-green {
    width: 420px;
    height: 420px;
    right: -80px;
    bottom: 40px;
    background: rgba(18, 110, 86, 0.35);
    animation-delay: -3s;
}

.ornament-star, .crescent {
    position: absolute;
    filter: drop-shadow(0 0 12px rgba(240, 215, 140, 0.35));
}

.star-large {
    width: 180px;
    left: 8%;
    top: 16%;
    animation: spin 46s linear infinite;
}

.star-small {
    width: 54px;
    right: 18%;
    top: 22%;
    animation: twinkle 3.6s ease-in-out infinite;
}

.crescent {
    width: 92px;
    right: 9%;
    top: 11%;
    animation: float 6.5s ease-in-out infinite;
}

.skyline {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 180px;
}

.skyline-stroke {
    stroke-dasharray: 7 8;
    animation: march 18s linear infinite;
}

.login-wrap {
    position: relative;
    z-index: 2;
    width: min(520px, calc(100% - 28px));
    display: grid;
    place-items: center;
    margin-bottom: 64px;
}

.halo {
    position: absolute;
    width: min(540px, 92vw);
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px dashed rgba(240, 215, 140, 0.38);
    animation: spin 70s linear infinite;
}

.halo::before,
.halo::after {
    content: "";
    position: absolute;
    width: 9px;
    height: 9px;
    background: var(--gold-soft);
    transform: rotate(45deg);
}

.halo::before { top: -5px; left: calc(50% - 4px); }
.halo::after { bottom: 18%; right: 6%; }

.login-card {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    padding: 36px 32px 26px;
    background:
        linear-gradient(180deg, rgba(255, 250, 242, 0.97), rgba(246, 236, 214, 0.96));
    border: 1px solid rgba(212, 175, 55, 0.75);
    border-radius: 18px;
    box-shadow:
        0 0 0 7px rgba(4, 22, 18, 0.28),
        0 0 0 8px rgba(212, 175, 55, 0.35),
        var(--shadow);
    animation: rise 0.9s ease both;
}

.corner {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid var(--gold);
}

.corner-tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.corner-tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }
.corner-bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; }
.corner-br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

.bismillah {
    margin: 0;
    text-align: center;
    font-family: var(--sans), var(--urdu);
    font-size: 0.98rem;
    line-height: 1.7;
    color: #6d5420;
}

.ornament {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px auto 6px;
    width: min(220px, 70%);
}

.ornament span {
    height: 1px;
    flex: 1;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.ornament i {
    width: 8px;
    height: 8px;
    background: var(--gold);
    transform: rotate(45deg);
}

.login-card h1,
.hero-panel h2,
.panel h2,
.topbar h1,
.brand strong {
    font-family: var(--display), var(--urdu);
    font-weight: 600;
}

.login-card h1 {
    margin: 0;
    text-align: center;
    font-size: 2.7rem;
    line-height: 1.2;
    letter-spacing: 0;
    color: #12382d;
}

.lede {
    margin: 0 0 18px;
    text-align: center;
    color: #6c5b43;
    display: grid;
    gap: 2px;
}

.arabic-line {
    font-family: var(--arabic);
    font-size: 1.35rem;
    color: #6d5420;
}

.stack, .form-grid { display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }

.field.is-hidden { display: none; }

.field span,
.panel-head p,
.quiet {
    color: #6d5b32;
}

.field .bi {
    font-size: 0.95rem;
    line-height: 1.45;
}

.field input,
.field select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #e4d3a4;
    background: #fffdf8;
    color: var(--ink);
    outline: none;
}

.field input:focus,
.field select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.22);
}

.field-error { color: var(--danger); }

.remember {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4e4332;
    font-size: 0.95rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    border-radius: 12px;
    padding: 12px 18px;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
}

.btn-gold {
    color: #2a2108;
    background: linear-gradient(180deg, #f6e3a6 0%, #e0c15a 42%, #c49a2c 100%);
    box-shadow: 0 8px 18px rgba(141, 107, 29, 0.28);
}

.btn-gold:hover { filter: brightness(1.05); }

.btn-block { width: 100%; margin-top: 4px; }

.btn-small { padding: 8px 12px; border-radius: 10px; font-size: 0.86rem; }

.btn-danger { background: var(--danger); color: #fff8ee; }

.btn-enable { background: var(--ok); color: #f6f0e4; }

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.alert-danger {
    background: #f8e8e4;
    color: #6d2424;
    border: 1px solid #e7b8b0;
}

.alert-success {
    background: #e7f4ee;
    color: #0f513c;
    border: 1px solid #b7dfcf;
}

.app-body { background: #efe6d4; min-height: 100vh; }

.app-shell { min-height: 100vh; display: flex; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 14px 10px 12px;
    color: var(--cream);
    background:
        linear-gradient(180deg, rgba(212, 175, 55, 0.08), transparent 28%),
        linear-gradient(180deg, #0c4638 0%, #041910 100%);
    border-right: 1px solid rgba(212, 175, 55, 0.28);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 6px 10px;
    border-bottom: 1px solid rgba(240, 215, 140, 0.2);
}

.brand strong {
    display: block;
    font-size: 1.28rem;
    line-height: 1.15;
}

.brand small {
    display: block;
    color: var(--gold-soft);
    font-size: 0.82rem;
    line-height: 1.45;
}

.brand-mark {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid rgba(240, 215, 140, 0.6);
    background: rgba(255, 255, 255, 0.04);
}

.brand-mark svg { width: 22px; height: 22px; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 12px;
}

.side-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    text-decoration: none;
    color: #f7f1e4;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(240, 215, 140, 0.22);
    border-radius: 10px;
    padding: 5px 8px;
    font-size: 0.86rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.side-btn:hover,
.side-btn.is-active {
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.28), rgba(212, 175, 55, 0.06));
    border-color: var(--gold);
    color: #fff8e4;
    transform: translateX(3px);
}

.side-group {
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(240, 215, 140, 0.45);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
}

.side-group .side-btn {
    border: 0;
    border-radius: 0;
    background: transparent;
}

.side-group .side-btn + .side-btn {
    border-top: 1px solid rgba(240, 215, 140, 0.28);
}

.side-group .side-btn:hover,
.side-group .side-btn.is-active {
    transform: none;
}

.side-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: rgba(240, 215, 140, 0.12);
}

.side-icon svg { width: 14px; height: 14px; }

.sidebar-foot {
    margin-top: auto;
    display: grid;
    gap: 8px;
    padding-top: 10px;
}

.who {
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
}

.who-name {
    display: block;
    font-weight: 600;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.who-role {
    display: inline-block;
    margin-top: 6px;
    color: #1c1404;
    background: var(--gold-soft);
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.45;
}

.side-btn-logout:hover {
    background: rgba(138, 48, 48, 0.45);
    border-color: #e0a0a0;
}

.workspace { flex: 1; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 28px;
    background: rgba(255, 250, 242, 0.92);
    border-bottom: 1px solid rgba(212, 175, 55, 0.28);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h1 { margin: 0; font-size: 1.7rem; line-height: 1.25; color: #12382d; }

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    padding: 10px;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    height: 2px;
    background: #12382d;
}

.content { padding: 28px; max-width: 1080px; }

.hero-panel, .panel {
    background: var(--parchment);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 10px 30px rgba(70, 48, 12, 0.05);
}

.hero-panel { margin-bottom: 18px; }

.eyebrow {
    margin: 0 0 4px;
    color: #6d5420;
    font-size: 1.05rem;
}

.hero-panel h2 {
    margin: 4px 0 8px;
    font-size: 2.15rem;
    line-height: 1.25;
    color: #12382d;
    overflow-wrap: anywhere;
}

.hero-panel p { margin: 0; max-width: 62ch; line-height: 1.6; color: #4e4332; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    background: linear-gradient(180deg, #0f4c3c, #0b3a2e);
    color: var(--cream);
    border-radius: 16px;
    padding: 16px 18px;
    border: 1px solid rgba(240, 215, 140, 0.3);
}

.stat-card .bi {
    display: block;
    font-size: 0.86rem;
    line-height: 1.45;
    color: var(--gold-soft);
}

.stat-card strong {
    display: block;
    margin-top: 6px;
    font-family: var(--sans), var(--urdu);
    font-size: 2.4rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.panel + .panel { margin-top: 18px; }

.panel-head h2 { margin: 0 0 4px; font-size: 1.8rem; color: #12382d; }

.panel-head p { margin: 0 0 16px; }

.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1100px) {
    .form-grid { grid-template-columns: 1fr; }
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    grid-column: 1 / -1;
}

.span-all { grid-column: 1 / -1; }

.checks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4e4332;
}

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

.user-table form { margin: 0; }

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

.panel-head-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-head-row p { margin-bottom: 0; }

.panel-head-row .btn { flex: none; }

.popup {
    width: min(480px, calc(100% - 28px));
    border: 1px solid rgba(212, 175, 55, 0.75);
    border-radius: 18px;
    padding: 20px;
    background: var(--parchment);
    color: var(--ink);
    box-shadow: var(--shadow);
}

.popup::backdrop {
    background: rgba(4, 25, 16, 0.55);
}

.popup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.popup-head h2 {
    margin: 0;
    font-size: 1.6rem;
    color: #12382d;
}

.popup-close {
    border: 0;
    background: transparent;
    color: #6d5420;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.category-tools {
    display: grid;
    gap: 16px;
}

.category-tool {
    display: grid;
    gap: 10px;
}

.category-tool + .category-tool {
    padding-top: 16px;
    border-top: 1px solid rgba(212, 175, 55, 0.35);
}

.category-tool .btn { justify-self: start; }

.bill-total {
    margin: 14px 0 0;
    text-align: right;
    font-size: 1.15rem;
    font-weight: 700;
    color: #12382d;
}

.line-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.line-qty input {
    width: 88px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #e4d3a4;
    background: #fffdf8;
    color: var(--ink);
}

.filter-row {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-row .field { min-width: min(100%, 280px); }

.filter-row .btn { margin-bottom: 1px; }

.user-table { width: 100%; border-collapse: collapse; min-width: 760px; }

.user-table td { overflow-wrap: break-word; }

.user-table th {
    text-align: left;
    font-size: 0.86rem;
    font-weight: 600;
    color: #6d5420;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.4);
}

.user-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.18);
    vertical-align: middle;
}

.is-muted { opacity: 0.72; }

.pill, .status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.pill { margin-left: 6px; background: #efe1b8; color: #5c4814; }

.status.is-on { background: #e3f5ec; color: #0f513c; }
.status.is-off { background: #f8e8e4; color: #6d2424; }

.backdrop { display: none; }

@media (max-width: 700px) {
    .menu-toggle { display: flex; }

    .sidebar {
        position: fixed;
        z-index: 30;
        transform: translateX(-105%);
        transition: transform 0.28s ease;
    }

    .sidebar.is-open { transform: translateX(0); }

    .backdrop.is-open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 20;
    }

    .content { padding: 18px; }
    .stat-grid, .form-grid { grid-template-columns: 1fr; }
    .login-card h1 { font-size: 2.8rem; }
    .hero-panel h2 { font-size: 2.1rem; }
}

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

@keyframes drift {
    to { transform: translate(-80px, -80px); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-14px); }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@keyframes twinkle {
    0%, 100% { opacity: 0.35; transform: scale(0.92); }
    50% { opacity: 1; transform: scale(1); }
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 0.75; }
}

@keyframes shimmer {
    to { background-position: 220% center; }
}

@keyframes march {
    to { stroke-dashoffset: -240; }
}

.bi {
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.45;
}

.bi-ur {
    font-family: var(--urdu);
    font-weight: 400;
    font-size: 1.22em;
    line-height: 1.8;
    letter-spacing: 0;
    text-transform: none;
    unicode-bidi: isolate;
}

.field .bi-ur,
.user-table .bi-ur,
.report-table .bi-ur,
.report-totals .bi-ur,
.btn .bi-ur,
.side-btn .bi-ur {
    white-space: nowrap;
}

.brand strong .bi-ur,
.login-card h1 .bi-ur,
.topbar h1 .bi-ur,
.hero-panel h2 .bi-ur,
.panel h2 .bi-ur {
    font-size: 1.05em;
    line-height: 1.5;
}

.brand small {
    padding-top: 0.35rem;
}

.side-btn .bi {
    line-height: 1.15;
    min-width: 0;
}

.side-btn .bi-ur {
    font-size: 1.05em;
    line-height: 1.35;
}

.btn .bi {
    line-height: 1.35;
}

.status,
.pill {
    line-height: 1.4;
    white-space: normal;
}

.btn-enable {
    text-decoration: none;
}

.pager {
    margin-top: 16px;
}

.report-sheet {
    width: min(210mm, 100%);
    margin: 18px auto 0;
    background: #fff;
    color: #1c1712;
    border: 1px solid rgba(212, 175, 55, 0.45);
    border-radius: 8px;
    padding: 18mm 14mm;
    box-shadow: 0 10px 30px rgba(70, 48, 12, 0.06);
}

.report-head {
    text-align: center;
    border-bottom: 1px solid rgba(212, 175, 55, 0.55);
    margin-bottom: 14px;
    padding-bottom: 10px;
}

.report-brand {
    margin: 0;
    letter-spacing: 0.08em;
    text-transform: none;
    color: #6d5420;
}

.report-head h2 {
    margin: 4px 0 8px;
    font-family: var(--display), var(--urdu);
    font-size: 1.8rem;
    color: #12382d;
}

.report-head p {
    margin: 2px 0;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
}

.report-table th,
.report-table td {
    border-bottom: 1px solid #eadfc8;
    padding: 8px 6px;
    text-align: left;
    vertical-align: top;
}

.report-table th {
    color: #6d5420;
    font-weight: 600;
}

.report-table .num,
.report-totals {
    text-align: right;
}

.report-totals {
    margin-top: 14px;
}

.report-totals p {
    margin: 4px 0;
}

.report-totals .grand {
    font-size: 1.15rem;
    font-weight: 700;
    color: #12382d;
}

.report-figures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0 4px;
}

.report-figure {
    border: 1px solid #eadfc8;
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
}

.report-figure .bi {
    color: #6d5420;
    font-size: 0.92rem;
}

.report-figure strong {
    display: block;
    margin-top: 4px;
    font-size: 1.05rem;
    color: #12382d;
}

.report-figure.is-profit,
.report-totals .is-profit {
    color: #146c43;
}

.report-figure.is-loss,
.report-totals .is-loss {
    color: #8d2b2b;
}

.report-figure.is-profit { border-color: #9dceb6; }
.report-figure.is-loss { border-color: #e3b4b4; }

.report-section { margin-top: 18px; }

.report-section h3 {
    margin: 0 0 8px;
    font-family: var(--display), var(--urdu);
    font-size: 1.35rem;
    color: #12382d;
}

@page {
    size: A4 portrait;
    margin: 12mm;
}

@media print {
    body.app-body {
        background: #fff;
    }

    .sidebar,
    .topbar,
    .backdrop,
    .no-print,
    .alert {
        display: none !important;
    }

    .app-shell,
    .workspace,
    .content {
        display: block;
        width: auto;
        max-width: none;
        padding: 0;
        margin: 0;
        background: #fff;
    }

    .report-sheet {
        width: auto;
        margin: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
    }

    .report-table tr,
    .report-head,
    .report-totals,
    .report-figure {
        break-inside: avoid;
    }

    .report-table thead {
        display: table-header-group;
    }
}
