:root {
    --bg: #f7f7f8;
    --surface: #ffffff;
    --ink: #202124;
    --muted: #6b7280;
    --line: #e5e7eb;
    --accent: #c85f77;
    --accent-strong: #a7465d;
    --teal: #197278;
    --danger: #b42318;
    --success: #147d64;
    --warning: #a15c07;
    --shadow: 0 10px 30px rgba(25, 31, 43, .08);
}

* {
    box-sizing: border-box;
}

html {
    direction: rtl;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 248px 1fr;
}

.sidebar {
    background: #ffffff;
    border-left: 1px solid var(--line);
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.brand small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.nav {
    display: grid;
    gap: 5px;
}

.nav a,
.nav button {
    border: 0;
    width: 100%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #374151;
    cursor: pointer;
}

.nav a.active,
.nav a:hover,
.nav button:hover {
    background: #f1f5f9;
    color: var(--ink);
}

.main {
    min-width: 0;
    padding: 22px 22px 88px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
}

.topbar h1 {
    margin: 0 0 6px;
    font-size: 26px;
}

.topbar p {
    margin: 0;
    color: var(--muted);
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 8px;
    min-height: 42px;
    padding: 9px 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn.primary:hover {
    background: var(--accent-strong);
}

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

.grid {
    display: grid;
    gap: 12px;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    box-shadow: var(--shadow);
}

.metric {
    display: block;
}

.metric strong {
    display: block;
    font-size: 26px;
    margin-top: 8px;
}

.metric span {
    color: var(--muted);
}

.section {
    margin-top: 18px;
}

.section h2 {
    margin: 0 0 10px;
    font-size: 18px;
}

.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.field {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

.field label {
    font-size: 13px;
    color: #374151;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    min-height: 42px;
    padding: 9px 11px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

th,
td {
    padding: 11px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    vertical-align: top;
}

th {
    font-size: 13px;
    color: var(--muted);
    background: #fafafa;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 4px 10px;
    color: #fff;
    background: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.muted {
    color: var(--muted);
}

.amount {
    font-variant-numeric: tabular-nums;
    direction: ltr;
    display: inline-block;
}

.flash {
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: #ecfdf5;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

.flash.error {
    background: #fef2f2;
    color: var(--danger);
    border-color: #fecaca;
}

.timeline {
    display: grid;
    gap: 10px;
}

.timeline-item {
    border-right: 3px solid var(--accent);
    padding: 6px 10px;
    background: #fff;
    border-radius: 8px;
}

.item-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.item-card img {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    object-fit: cover;
    background: #f3f4f6;
}

.production-head {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.production-image {
    width: 132px;
    height: 132px;
    border-radius: 8px;
    object-fit: cover;
    background: #f3f4f6;
    flex: 0 0 auto;
}

.production-image.placeholder {
    display: grid;
    place-items: center;
    color: var(--muted);
    border: 1px dashed var(--line);
}

.qr-card {
    text-align: center;
}

.qr-card img {
    width: 220px;
    max-width: 100%;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: #fff;
}

.quick-stage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.quick-stage-grid .btn {
    width: 100%;
}

.custom-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.option-pill {
    background: #fdf2f8;
    color: #9d174d;
    border: 1px solid #fbcfe8;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
}

.bottom-nav {
    display: none;
}

.fab {
    position: fixed;
    left: 18px;
    bottom: 78px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: none;
    place-items: center;
    font-size: 30px;
    box-shadow: var(--shadow);
    z-index: 20;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-box {
    width: min(420px, 100%);
}

.print-only {
    display: none;
}

@media (max-width: 980px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .main {
        padding: 16px 12px 96px;
    }

    .topbar {
        display: grid;
    }

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

    .section.grid {
        grid-template-columns: 1fr !important;
    }

    .production-card {
        grid-template-columns: 1fr !important;
    }

    .production-head {
        display: grid;
    }

    .production-image {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
        max-height: 260px;
    }

    .bottom-nav {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        position: fixed;
        right: 0;
        left: 0;
        bottom: 0;
        background: #fff;
        border-top: 1px solid var(--line);
        z-index: 15;
    }

    .bottom-nav a {
        min-height: 64px;
        display: grid;
        place-items: center;
        gap: 2px;
        font-size: 12px;
        color: var(--muted);
    }

    .bottom-nav a.active {
        color: var(--accent);
    }

    .fab {
        display: grid;
    }

    .table-wrap {
        overflow: visible;
    }

    table.mobile-cards,
    table.mobile-cards thead,
    table.mobile-cards tbody,
    table.mobile-cards tr,
    table.mobile-cards th,
    table.mobile-cards td {
        display: block;
        width: 100%;
    }

    table.mobile-cards {
        border: 0;
        background: transparent;
    }

    table.mobile-cards thead {
        display: none;
    }

    table.mobile-cards tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 10px;
        box-shadow: var(--shadow);
    }

    table.mobile-cards td {
        border: 0;
        padding: 6px 0;
    }

    table.mobile-cards td::before {
        content: attr(data-label);
        display: block;
        color: var(--muted);
        font-size: 12px;
        margin-bottom: 2px;
    }
}

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

    .topbar h1 {
        font-size: 22px;
    }

    .actions .btn,
    .toolbar .btn {
        width: 100%;
    }
}

@media print {
    .sidebar,
    .bottom-nav,
    .fab,
    .actions,
    .no-print {
        display: none !important;
    }

    .app-shell,
    .main {
        display: block;
        padding: 0;
    }

    body {
        background: #fff;
    }

    .card {
        box-shadow: none;
    }

    .production-card {
        grid-template-columns: 2fr 1fr !important;
    }

    .qr-card img {
        width: 170px;
    }
}
