/* assets/style.css */
:root {
    --bg: #eef2f7;
    --bg-soft: #f8fafc;
    --panel: rgba(255,255,255,.88);
    --text: #0f172a;
    --muted: #64748b;
    --line: #dbe3ef;
    --primary: #155eef;
    --primary-dark: #0f46bd;
    --green: #0f8a4b;
    --amber: #b45309;
    --red: #b91c1c;
    --purple: #6d28d9;
    --shadow: 0 24px 80px rgba(15,23,42,.12);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(21,94,239,.18), transparent 32rem),
        radial-gradient(circle at top right, rgba(109,40,217,.13), transparent 30rem),
        linear-gradient(135deg, #eef2f7, #f8fafc 55%, #eef2ff);
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.app-header {
    width: min(1480px, calc(100% - 32px));
    margin: 24px auto 0;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(219,227,239,.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.app-header h1,
.panel h2,
.empty-state h3 {
    margin: 0;
    letter-spacing: -.04em;
}

.app-header h1 {
    font-size: clamp(1.6rem, 3vw, 2.6rem);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .14em;
}

nav {
    display: flex;
    gap: 10px;
}

.nav-link,
.ghost-btn,
.primary-btn,
button {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 800;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.nav-link {
    padding: 10px 16px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
}

.nav-link.active,
.primary-btn {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 12px 32px rgba(21,94,239,.26);
}

.nav-link:hover,
button:hover,
.ghost-btn:hover,
.primary-btn:hover {
    transform: translateY(-1px);
}

.layout {
    width: min(1480px, calc(100% - 32px));
    margin: 24px auto 48px;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(330px, .7fr);
    gap: 24px;
}

.admin-layout {
    grid-template-columns: 1fr;
}

.panel {
    background: var(--panel);
    border: 1px solid rgba(219,227,239,.92);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    backdrop-filter: blur(18px);
}

.full-width {
    grid-column: 1 / -1;
}

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

.panel-head.compact {
    margin-bottom: 14px;
}

.panel h2 {
    font-size: 1.35rem;
}

.cutoff-pill,
.warning-pill,
.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 900;
}

.cutoff-pill {
    color: #1e3a8a;
    background: #dbeafe;
}

.warning-pill {
    color: #7c2d12;
    background: #ffedd5;
}

.notice {
    margin-bottom: 14px;
    padding: 13px 16px;
    border-radius: 18px;
    font-weight: 800;
}

.notice.success {
    color: #065f46;
    background: #d1fae5;
}

.notice.error {
    color: #991b1b;
    background: #fee2e2;
}

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

label {
    display: grid;
    gap: 8px;
    color: #334155;
    font-size: .88rem;
    font-weight: 900;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
    outline: none;
    box-shadow: inset 0 1px 0 rgba(15,23,42,.03);
}

textarea {
    resize: vertical;
    min-height: 104px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(21,94,239,.55);
    box-shadow: 0 0 0 4px rgba(21,94,239,.10);
}

.primary-btn,
.order-form button,
.status-form button,
.date-switcher button,
.overdue-card button,
.product-admin-card button {
    padding: 12px 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
}

.danger-btn {
    background: linear-gradient(135deg, #ef4444, #b91c1c) !important;
}

.product-comment {
    color: #1e3a8a;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 18px;
    padding: 14px 16px;
    font-weight: 700;
}

.time-help-box {
    color: #475569;
    background: #f8fafc;
    border-color: #dbe3ef;
    font-size: .88rem;
    line-height: 1.48;
}

.sidebar-gap {
    margin-top: 16px;
}

.sidebar-panel {
    align-self: start;
}

.date-switcher {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-bottom: 16px;
}

.production-date-switcher {
    margin-bottom: 22px;
}

.panel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.system-time {
    margin: 8px 0 0;
    color: var(--muted);
    font-weight: 800;
}

.system-time strong {
    color: var(--text);
}

.summary-card,
.empty-state {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 18px;
}

.totals-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.totals-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--line);
}

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

.overdue-grid,
.product-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.overdue-card,
.product-admin-card {
    padding: 18px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid var(--line);
}

.overdue-card strong {
    display: block;
    font-size: 1.15rem;
}

.admin-note {
    color: #7c2d12;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 14px;
    padding: 10px 12px;
}

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

.orders-table {
    width: 100%;
    min-width: 980px;
    border-collapse: separate;
    border-spacing: 0 10px;
}

.production-table {
    min-width: 1060px;
}

.allorders-table {
    min-width: 1180px;
}

.allorders-filter-form {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
}

.allorders-filter-form label {
    min-width: 0;
}

.allorders-filter-form button {
    min-height: 47px;
}

.checkbox-card {
    min-height: 47px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    color: #334155;
}

.checkbox-card input {
    width: auto;
}

.print-only {
    display: none;
}

.orders-table th {
    color: var(--muted);
    font-size: .76rem;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: 0 12px 6px;
}

.orders-table td {
    padding: 14px 12px;
    background: #fff;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.orders-table td:first-child {
    border-left: 1px solid var(--line);
    border-radius: 18px 0 0 18px;
}

.orders-table td:last-child {
    border-right: 1px solid var(--line);
    border-radius: 0 18px 18px 0;
}

.orders-table tr.order-completed td {
    background: #ecfdf5;
    border-color: #bbf7d0;
}

.orders-table tr.order-completed td:first-child {
    box-shadow: inset 5px 0 0 #22c55e;
}

.orders-table tr.order-skipped td {
    background: #fff7ed;
    border-color: #fed7aa;
}

.orders-table tr.order-cancelled td {
    background: #fef2f2;
    border-color: #fecaca;
    opacity: .72;
}

.orders-table tr.order-late-time td {
    background: #fef2f2;
    border-color: #fecaca;
}

.orders-table tr.order-late-time td:first-child {
    box-shadow: inset 5px 0 0 #ef4444;
}

.orders-table small {
    display: block;
    margin-top: 4px;
    color: var(--purple);
    font-weight: 900;
}

.comments-cell {
    max-width: 360px;
}

.comments-cell p {
    margin: 0 0 8px;
}

.status {
    min-width: 108px;
}

.status-pending {
    color: #92400e;
    background: #fef3c7;
}

.status-progress {
    color: #1e3a8a;
    background: #dbeafe;
}

.status-completed {
    color: #065f46;
    background: #d1fae5;
}

.status-skipped {
    color: #7c2d12;
    background: #ffedd5;
}

.status-cancelled {
    color: #991b1b;
    background: #fee2e2;
}

.late-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    color: #fff;
    background: #dc2626;
    font-size: .72rem;
    font-weight: 950;
    letter-spacing: .04em;
}

.time-note {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 800;
}

.optional-label {
    color: var(--muted);
    font-size: .74rem;
    font-weight: 800;
}

.late-warning-panel {
    margin-bottom: 18px;
    padding: 16px 18px;
    border-radius: 20px;
    color: #7f1d1d;
    background: #fee2e2;
    border: 1px solid #fecaca;
    font-weight: 800;
}

.late-warning-panel strong {
    display: block;
    margin-bottom: 5px;
    font-size: 1.05rem;
}

.late-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(127, 29, 29, .42);
    backdrop-filter: blur(8px);
}

.late-modal-card {
    width: min(520px, 100%);
    padding: 24px;
    border-radius: 26px;
    background: #fff;
    border: 2px solid #fecaca;
    box-shadow: 0 30px 120px rgba(127, 29, 29, .35);
}

.late-modal-card h2 {
    margin: 0 0 10px;
    color: #991b1b;
}

.late-modal-list {
    margin: 14px 0;
    padding-left: 18px;
    color: #7f1d1d;
    font-weight: 800;
}

.late-modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.status-form {
    display: grid;
    gap: 8px;
    min-width: 220px;
}

.compact-status-form {
    min-width: 250px;
}

.compact-status-form select,
.compact-status-form input,
.compact-status-form button {
    min-height: 44px;
}

.production-table td:nth-child(1) {
    min-width: 90px;
}

.production-table td:nth-child(4) {
    min-width: 110px;
}

.production-table td:nth-child(5) {
    min-width: 130px;
}

.production-table td:nth-child(6) {
    min-width: 260px;
}

.production-table td:nth-child(7) {
    min-width: 270px;
}

.allorders-table td:nth-child(1) {
    min-width: 110px;
}

.allorders-table td:nth-child(2) {
    min-width: 130px;
}

.allorders-table td:nth-child(5) {
    min-width: 130px;
}

.allorders-table td:nth-child(7) {
    min-width: 320px;
}

.allorders-table td:nth-child(8) {
    min-width: 135px;
}

.product-admin-card {
    position: relative;
}

.product-admin-card.is-disabled {
    opacity: .58;
}

.product-admin-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.toggle-label {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 10px;
}

.toggle-label input {
    width: auto;
}

.card-actions {
    margin-top: 10px;
}

.delete-form {
    margin-top: 10px;
}

.delete-form button,
.card-actions button {
    width: 100%;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15,23,42,.62);
    backdrop-filter: blur(8px);
}

.modal-card {
    width: min(460px, 100%);
    padding: 24px;
    border-radius: 26px;
    background: #fff;
    box-shadow: 0 30px 120px rgba(0,0,0,.35);
}

.modal-card h2 {
    margin: 0 0 10px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

[hidden] {
    display: none !important;
}

/* Hub page */
.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.hub-card {
    display: grid;
    gap: 11px;
    padding: 24px;
    color: var(--text);
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 14px 42px rgba(15,23,42,.08);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.hub-card:hover {
    transform: translateY(-2px);
    border-color: rgba(21,94,239,.42);
    box-shadow: 0 22px 64px rgba(15,23,42,.13);
}

.hub-icon {
    width: 64px;
    min-width: 64px;
    height: 50px;
    display: grid;
    place-items: center;
    border-radius: 17px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    font-size: 1.05rem;
    font-weight: 950;
    letter-spacing: .03em;
    box-shadow: 0 12px 28px rgba(21,94,239,.22);
}

.hub-card strong {
    font-size: 1.14rem;
    letter-spacing: -.02em;
}

.hub-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.48;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(15,23,42,.05);
}

.stat-card strong {
    display: block;
    font-size: 2.05rem;
    line-height: 1;
    letter-spacing: -.06em;
}

.stat-card span {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-weight: 800;
}

.stat-warning {
    background: #fff7ed;
    border-color: #fed7aa;
}

.hub-summary {
    margin-top: 10px;
}

@media print {
    @page {
        margin: 12mm;
    }

    body {
        background: #fff;
    }

    .app-header,
    .panel-actions,
    nav,
    .date-switcher,
    .status-form,
    .ghost-btn,
    .primary-btn,
    button,
    .late-modal,
    .print-hide {
        display: none !important;
    }

    .layout,
    .panel,
    .orders-table {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
    }

    .layout {
        display: block;
    }

    .panel {
        border: 0;
        padding: 0;
    }

    .orders-table-wrap {
        overflow: visible;
    }

    .orders-table th,
    .orders-table td {
        font-size: 11px;
        padding: 7px;
        background: #fff !important;
        color: #000 !important;
        border-color: #bbb !important;
    }

    .print-only {
        display: block !important;
    }

    .status,
    .late-badge,
    .time-note,
    .admin-note {
        color: #000 !important;
        background: transparent !important;
        border: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
}

@media (max-width: 1200px) {
    .allorders-filter-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .app-header,
    .layout,
    .panel-head,
    .app-header nav {
        width: min(100% - 20px, 1480px);
    }

    .app-header,
    .panel-head {
        flex-direction: column;
        align-items: stretch;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .order-form {
        grid-template-columns: 1fr;
    }

    .date-switcher {
        grid-template-columns: 1fr;
    }

    nav {
        width: 100%;
    }

    .nav-link {
        flex: 1;
        text-align: center;
    }

    .span-2 {
        grid-column: auto;
    }
}
