@import url('./schedule.css');
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    color-scheme: light;
    --ink: #17221c;
    --muted: #748078;
    --soft: #f5f7f6;
    --surface: #fff;
    --line: #e7ebe8;
    --green: #19734b;
    --green-dark: #105a39;
    --green-soft: #eaf5ef;
    --shadow: 0 1px 2px rgb(21 42 29 / 4%), 0 10px 30px rgb(21 42 29 / 4%);
    font-family: Manrope, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--soft); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed; z-index: 20; inset: 0 auto 0 0; display: flex; width: 246px; padding: 30px 18px 22px;
    flex-direction: column; background: #fff; border-right: 1px solid var(--line);
}
.brand { display: flex; gap: 11px; align-items: center; padding: 0 8px; color: var(--ink); text-decoration: none; font-size: 19px; font-weight: 800; letter-spacing: -.04em; }
.brand > span:last-child span { color: var(--green); }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; background: var(--green); color: #fff; box-shadow: 0 7px 16px rgb(25 115 75 / 20%); }
.brand-mark svg { width: 20px; stroke-width: 2.2; }
.nav { margin-top: 48px; }
.nav-label { margin: 0 12px 10px; color: #a0a9a3; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-item { display: flex; min-height: 46px; margin-bottom: 5px; padding: 0 12px; gap: 12px; align-items: center; border-radius: 11px; color: #667169; text-decoration: none; font-size: 14px; font-weight: 600; }
.nav-item svg { width: 19px; }
.nav-item.active { background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
.nav-item.disabled { opacity: .55; cursor: default; }
.nav-item small { margin-left: auto; padding: 2px 6px; border-radius: 5px; background: #f0f2f1; font-size: 8px; letter-spacing: .06em; text-transform: uppercase; }
.sidebar-foot { margin-top: auto; padding: 0 10px; color: #a0a9a3; font-size: 10px; }

.main { min-height: 100vh; margin-left: 246px; }
.topbar { display: flex; min-height: 104px; padding: 0 42px; align-items: center; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 88%); backdrop-filter: blur(16px); }
.breadcrumbs { margin: 0 0 6px; color: #9aa39d; font-size: 11px; font-weight: 600; }
.breadcrumbs span { margin: 0 7px; color: #c5cbc7; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.035em; }
.profile { display: flex; margin-left: auto; gap: 10px; align-items: center; }
.logout-button { margin-left: 18px; }
.profile > span:last-child { display: grid; }
.profile strong { font-size: 11px; }
.profile small { margin-top: 2px; color: #9aa39d; font-size: 9px; }
.avatar { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 50%; background: #dfeee5; color: var(--green-dark); font-size: 12px; font-weight: 800; }
.icon-button { display: grid; padding: 0; place-items: center; border: 0; background: transparent; color: var(--ink); }
.menu-button { display: none; width: 40px; height: 40px; margin-right: 10px; }

.content { width: min(1240px, calc(100% - 80px)); margin: 0 auto; padding: 40px 0 64px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; }
.intro h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.04em; }
.intro p { margin: 0; color: var(--muted); font-size: 12px; }
.secondary-button { display: flex; height: 38px; padding: 0 14px; gap: 8px; align-items: center; justify-content: center; border: 1px solid #dfe4e1; border-radius: 9px; background: #fff; color: #4c5951; font-size: 11px; font-weight: 700; box-shadow: 0 1px 2px rgb(20 40 25 / 3%); }
.secondary-button:hover { border-color: #c7d0ca; background: #fbfcfb; }
.secondary-button:disabled { cursor: wait; opacity: .7; }
.secondary-button svg { width: 15px; }
.rotating svg { animation: spin .8s linear infinite; }

.stats { display: grid; margin-top: 24px; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-card { display: flex; min-height: 94px; padding: 20px; gap: 15px; align-items: center; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: var(--shadow); }
.stat-icon { display: grid; width: 43px; height: 43px; flex: 0 0 43px; place-items: center; border-radius: 11px; }
.stat-icon svg { width: 20px; }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.blue { background: #edf3fb; color: #4778b4; }
.stat-icon.violet { background: #f2effa; color: #735ca6; }
.stat-card p { margin: 0 0 6px; color: var(--muted); font-size: 10px; font-weight: 600; }
.stat-card strong { font-size: 17px; letter-spacing: -.025em; }

.catalog-card { margin-top: 18px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; box-shadow: var(--shadow); scroll-margin-top: 20px; }
.catalog-toolbar { display: flex; min-height: 87px; padding: 20px 22px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.catalog-toolbar h3 { margin: 0 0 5px; font-size: 15px; letter-spacing: -.02em; }
.catalog-toolbar p { margin: 0; color: var(--muted); font-size: 10px; }
.search { position: relative; width: min(310px, 40%); }
.search > svg { position: absolute; top: 11px; left: 12px; width: 16px; color: #9ba49e; pointer-events: none; }
.search input { width: 100%; height: 39px; padding: 0 36px 0 37px; border: 1px solid #dfe4e1; border-radius: 9px; outline: 0; color: var(--ink); font-size: 11px; }
.search input::placeholder { color: #aab2ad; }
.search input:focus { border-color: #6ba186; box-shadow: 0 0 0 3px rgb(25 115 75 / 9%); }
.search button { position: absolute; top: 6px; right: 7px; width: 27px; height: 27px; border: 0; background: transparent; color: #929c95; font-size: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { height: 42px; padding: 0 16px; background: #fafbfa; color: #8c968f; font-size: 9px; font-weight: 800; letter-spacing: .055em; text-align: left; text-transform: uppercase; }
th:first-child, td:first-child { padding-left: 22px; }
th:last-child, td:last-child { padding-right: 22px; }
.catalog-table th:first-child { width: 7%; }
.catalog-table th:nth-child(2) { width: 40%; }
.catalog-table th:nth-child(3) { width: 9%; }
.catalog-table th:nth-child(4) { width: 17%; }
.catalog-table th:nth-child(5) { width: 15%; }
.catalog-table th:last-child { width: 12%; }
td { height: 70px; padding: 10px 16px; border-top: 1px solid #eff1f0; color: #536058; font-size: 10px; vertical-align: middle; }
tbody tr:hover { background: #fcfdfc; }
.row-number { color: #8c968f; font-weight: 700; }
.product-cell strong { display: block; overflow: hidden; color: #26332b; font-size: 10px; font-weight: 700; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.product-cell small { display: block; margin-top: 4px; color: #99a29c; font-size: 9px; }
.code, .barcode { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #6d7871; }
.price-cell { text-align: right; }
.price { color: #26332b; font-size: 11px; font-weight: 800; white-space: nowrap; }
.imports-table { table-layout: auto; }
.imports-table th:first-child, .imports-table td:first-child { width: auto; }
.imports-table th:nth-child(2), .imports-table th:nth-child(3), .imports-table th:nth-child(4), .imports-table th:last-child { width: auto; }
.imports-table td { height: 58px; }
.orders-table { table-layout: auto; }
.orders-table td { height: 64px; }
.order-number strong, .order-pharmacy strong, .order-customer strong { display: block; color: #26332b; font-size: 10px; }
.order-number small, .order-pharmacy small, .order-customer small { display: block; margin-top: 4px; color: #99a29c; font-size: 9px; }
.order-link { padding: 0; border: 0; background: transparent; color: var(--green); font-size: 10px; font-weight: 800; }
.order-link:hover { text-decoration: underline; }
.status-badge { display: inline-flex; padding: 5px 8px; align-items: center; border-radius: 7px; font-size: 9px; font-weight: 800; white-space: nowrap; }
.status-created { background: #fff5df; color: #8b6518; }
.status-sent { background: var(--green-soft); color: var(--green-dark); }
.status-failed { background: #fff0ef; color: #a33f39; }
.download-link { color: var(--green); font-weight: 700; text-decoration: none; }
.download-link:hover { text-decoration: underline; }

.order-dialog { width: min(900px, calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); box-shadow: 0 24px 80px rgb(10 30 18 / 24%); }
.order-dialog::backdrop { background: rgb(13 25 18 / 45%); backdrop-filter: blur(2px); }
.dialog-heading { display: flex; min-height: 76px; padding: 18px 22px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 18px; }
.dialog-close { width: 34px; height: 34px; border: 0; border-radius: 8px; background: var(--soft); color: #667169; font-size: 22px; line-height: 1; }
.dialog-message { padding: 48px 22px; color: var(--muted); font-size: 12px; text-align: center; }
.order-facts { display: grid; margin: 0; padding: 20px 22px; grid-template-columns: repeat(4, 1fr); gap: 18px; border-bottom: 1px solid var(--line); }
.order-facts div { min-width: 0; }
.order-facts dt { margin-bottom: 5px; color: #8c968f; font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.order-facts dd { margin: 0; overflow-wrap: anywhere; color: #26332b; font-size: 11px; font-weight: 700; }
.detail-table-wrap { max-height: 55vh; overflow: auto; }
.detail-table { table-layout: auto; }
.detail-table th:first-child { min-width: 220px; }
.detail-table td { height: 56px; }
.detail-table tfoot th, .detail-table tfoot td { height: 56px; border-top: 1px solid var(--line); background: #fafbfa; text-align: right; }
.detail-table tfoot td { color: #26332b; font-size: 11px; font-weight: 800; }

.pagination { display: flex; min-height: 62px; padding: 0 22px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); }
.pagination p { color: #8b958e; font-size: 10px; }
.page-controls, .page-controls > div { display: flex; gap: 4px; align-items: center; }
.page-controls button { display: grid; width: 30px; height: 30px; padding: 0; place-items: center; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #6f7b73; font-size: 10px; font-weight: 700; }
.page-controls button:hover:not(:disabled) { background: #f2f5f3; }
.page-controls button.active { background: var(--green); color: #fff; }
.page-controls button:disabled { cursor: default; opacity: .35; }
.page-controls svg { width: 15px; }
.page-controls span { width: 18px; color: #9da59f; text-align: center; font-size: 10px; }

.state { display: grid; min-height: 310px; padding: 40px; place-items: center; align-content: center; text-align: center; }
.state h3 { margin: 14px 0 5px; font-size: 15px; }
.state p { margin: 0 0 18px; color: var(--muted); font-size: 11px; }
.state-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; background: #fff0ef; color: #b34b45; font-weight: 800; }
.state-icon.muted { background: #f0f3f1; color: #839087; }
.state-icon svg { width: 19px; }
.loading-state { color: var(--muted); }
.loading-state p { margin-top: 12px; }
.spinner { width: 25px; height: 25px; border: 2px solid #e5ebe7; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
.mobile-backdrop { position: fixed; z-index: 15; inset: 0; width: 100%; border: 0; background: rgb(13 25 18 / 45%); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 920px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); box-shadow: 20px 0 50px rgb(10 20 14 / 16%); }
    .main { margin-left: 0; }
    .menu-button { display: grid; }
    .content { width: min(100% - 40px, 900px); }
}

@media (max-width: 680px) {
    .topbar { min-height: 84px; padding: 0 18px; }
    .profile > span:last-child { display: none; }
    .content { width: calc(100% - 28px); padding-top: 26px; }
    .stats { grid-template-columns: 1fr; }
    .stat-card { min-height: 80px; }
    .catalog-toolbar { display: block; }
    .search { width: 100%; margin-top: 16px; }
    table, tbody { display: block; }
    thead { display: none; }
    tbody { padding: 4px 14px; }
    tr { display: grid; padding: 14px 0; grid-template-columns: 1fr 1fr; gap: 12px; border-bottom: 1px solid var(--line); }
    tr:last-child { border-bottom: 0; }
    td { display: block; height: auto; padding: 0 !important; border: 0; }
    .catalog-table .row-number, .catalog-table .product-cell { grid-column: 1 / -1; }
    .product-cell strong { white-space: normal; }
    td::before { display: block; margin-bottom: 3px; color: #9aa39d; font-family: Manrope, sans-serif; font-size: 8px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
    .catalog-table td:nth-child(1)::before { content: '№'; }
    .catalog-table td:nth-child(3)::before { content: 'Код'; }
    .catalog-table td:nth-child(4)::before { content: 'Производитель'; }
    .catalog-table td:nth-child(5)::before { content: 'Штрихкод'; }
    .catalog-table td:nth-child(6)::before { content: 'Цена'; }
    .imports-table td:nth-child(1)::before { content: 'Когда'; }
    .imports-table td:nth-child(2)::before { content: 'Провайдер'; }
    .imports-table td:nth-child(3)::before { content: 'Файл'; }
    .imports-table td:nth-child(4)::before { content: 'Товаров'; }
    .imports-table td:nth-child(5)::before { content: 'Размер'; }
    .orders-table td:nth-child(1)::before { content: 'Заказ'; }
    .orders-table td:nth-child(2)::before { content: 'Создан'; }
    .orders-table td:nth-child(3)::before { content: 'Пользователь'; }
    .orders-table td:nth-child(4)::before { content: 'Аптека'; }
    .orders-table td:nth-child(5)::before { content: 'Позиций'; }
    .orders-table td:nth-child(6)::before { content: 'Единиц'; }
    .orders-table td:nth-child(7)::before { content: 'Сумма'; }
    .orders-table td:nth-child(8)::before { content: 'Статус'; }
    .order-facts { grid-template-columns: 1fr 1fr; }
    .detail-table { display: table; min-width: 680px; }
    .detail-table thead { display: table-header-group; }
    .detail-table tbody { display: table-row-group; padding: 0; }
    .detail-table tr { display: table-row; padding: 0; border: 0; }
    .detail-table td { display: table-cell; padding: 10px 16px !important; border-top: 1px solid #eff1f0; }
    .detail-table td::before { display: none; }
    .price-cell { text-align: left; }
    .pagination { display: grid; padding: 12px 14px 16px; justify-content: center; }
    .pagination p { margin: 0 0 10px; text-align: center; }
}

.sidebar-foot .build-version { display: block; margin-top: 8px; font-family: monospace; font-size: 12px; color: var(--muted); white-space: nowrap; }

.order-ready-actions { padding: 12px 22px; border-bottom: 1px solid var(--line); }
.order-ready-actions p { margin: 0 0 12px; }
#ready-error { margin-top: 12px; color: #a4262c; }
