:root {
    --navy: #101828;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --teal: #0f766e;
    --text: #182230;
    --muted: #667085;
    --bg: #f3f7fb;
    --card: #ffffff;
    --border: #d9e2ec;
    --green: #12b76a;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .04);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; font-family: Inter, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); }
body.menu-open { overflow: hidden; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.topbar { min-height: 72px; background: var(--navy); color: #fff; padding: 13px max(24px, calc((100% - 1500px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid #253044; }
.topbar-main, .topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-mark { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: #7dd3fc; background: #16324f; flex: 0 0 auto; }
.topbar-mark svg { width: 17px; }
h1 { margin: 0; font-size: 20px; line-height: 1.15; letter-spacing: 0; }
.topbar p { margin: 3px 0 0; color: #b8c4d6; font-size: 12px; }
.menu-toggle, .menu-close { display: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 7px; color: #e5edf7; background: #223049; cursor: pointer; align-items: center; justify-content: center; }
.menu-toggle svg, .menu-close svg { width: 21px; }
.theme-toggle { width: 40px; height: 40px; min-height: 40px; padding: 0; color: #dbeafe; background: #223049; border-color: #34445e; }
.theme-toggle:hover { background: #2d3d57; border-color: #4a5c77; }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-icon-sun { display: none; }
.language-switch { display: inline-flex; padding: 3px; background: #223049; border: 1px solid #34445e; border-radius: 7px; }
.language-switch a { min-width: 34px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center; color: #cbd5e1; border-radius: 5px; text-decoration: none; font-size: 12px; font-weight: 800; }
.language-switch a:hover { color: #fff; background: #2d3d57; }
.language-switch a.active { color: #0b1322; background: #f8fafc; }
.status { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; padding: 8px 12px; color: #067647; background: #ecfdf3; border: 1px solid #abefc6; border-radius: 999px; font-size: 12px; font-weight: 700; }
.dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; }
.app-shell { width: min(1500px, 100%); margin: 0 auto; padding: 24px; display: grid; grid-template-columns: 246px minmax(0, 1fr); gap: 24px; align-items: start; }
main { min-width: 0; }
.sidebar { position: sticky; top: 20px; height: calc(100vh - 40px); padding: 14px 10px; overflow-y: auto; background: #0b1322; border: 1px solid #1d2939; border-radius: 8px; box-shadow: 0 16px 36px rgba(16, 24, 40, .16); }
.brand { min-height: 58px; display: flex; align-items: center; gap: 11px; margin: 0 -10px 12px; padding: 7px 20px 17px; border-bottom: 1px solid #263348; }
.brand-icon { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; border-radius: 7px; color: #38bdf8; background: #12304b; }
.brand-icon svg { width: 16px; }
.brand strong { color: #f2f4f7; font-size: 18px; }
.menu-close { margin-left: auto; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar a { min-height: 46px; display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: #cbd5e1; border-radius: 7px; text-decoration: none; font-size: 14px; font-weight: 650; transition: background .16s ease, color .16s ease; }
.sidebar a svg { width: 19px; height: 19px; flex: 0 0 auto; color: #38bdf8; stroke-width: 1.9; }
.sidebar a:hover { color: #fff; background: #18263a; }
.sidebar a.active { color: #fff; background: var(--teal); box-shadow: inset 3px 0 #5eead4; }
.sidebar a.active svg { color: #ccfbf1; }
.sidebar-soon { margin: 24px 12px 10px; color: #98a2b3; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.muted-nav a { color: #8190a5; }
.muted-nav a svg { color: #60738e; }
.sidebar-backdrop { display: none; }
.notice { margin-bottom: 18px; padding: 15px 17px; color: #9a3412; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; }
.panel { margin-top: 18px; padding: 20px; overflow: auto; background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); scroll-margin-top: 18px; }
.filters { margin-top: 0; overflow: visible; }
h2 { margin: 0 0 16px; font-size: 18px; letter-spacing: 0; }
h3 { margin: 0 0 11px; font-size: 15px; }
.filters form { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; gap: 13px; align-items: end; margin: 0; }
.quick-periods { grid-column: 1 / -1; display: inline-flex; width: fit-content; max-width: 100%; overflow-x: auto; padding: 3px; background: #eef2f7; border: 1px solid #d5dee9; border-radius: 7px; }
.period-chip { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; padding: 7px 13px; color: #475467; border-radius: 5px; text-decoration: none; font-size: 12px; font-weight: 750; white-space: nowrap; }
.period-chip:hover { color: #182230; background: #fff; }
.period-chip.active { color: #fff; background: var(--blue); box-shadow: 0 2px 6px rgba(37, 99, 235, .2); }
label { min-width: 0; display: flex; flex-direction: column; gap: 6px; color: #475467; font-size: 11px; font-weight: 750; text-transform: uppercase; }
input, select { width: 100%; min-width: 0; height: 44px; padding: 9px 12px; color: var(--text); background: #fff; border: 1px solid #c8d3e1; border-radius: 7px; outline: none; text-transform: none; transition: border-color .15s ease, box-shadow .15s ease; }
input:focus, select:focus { border-color: #6695f2; box-shadow: 0 0 0 3px rgba(37, 99, 235, .11); }
.smart-select-native { display: none; }
.smart-select { position: relative; width: 100%; min-width: 0; text-transform: none; }
.smart-select-trigger { position: relative; width: 100%; min-height: 44px; padding: 9px 38px 9px 12px; justify-content: flex-start; overflow: hidden; color: var(--text); background: #fff; border: 1px solid #c8d3e1; border-radius: 7px; font-weight: 500; text-align: left; white-space: nowrap; text-overflow: ellipsis; }
.smart-select-trigger::after { content: ''; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; border-right: 2px solid #667085; border-bottom: 2px solid #667085; transform: translateY(-65%) rotate(45deg); transition: transform .16s ease; }
.smart-select-trigger:hover { color: var(--text); background: #fff; border-color: #98a2b3; }
.smart-select.open .smart-select-trigger { border-color: #6695f2; box-shadow: 0 0 0 3px rgba(37, 99, 235, .11); }
.smart-select.open .smart-select-trigger::after { transform: translateY(-20%) rotate(225deg); }
.smart-select-menu { position: absolute; z-index: 50; top: calc(100% + 6px); left: 0; width: max(100%, 240px); padding: 8px; background: #fff; border: 1px solid #c8d3e1; border-radius: 8px; box-shadow: 0 16px 34px rgba(16, 24, 40, .18); }
.smart-select-menu[hidden] { display: none; }
.smart-select-search { height: 40px; margin-bottom: 7px; padding-left: 11px; font-size: 13px; }
.smart-select-options { max-height: 230px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.smart-select-option { width: 100%; min-height: 39px; padding: 8px 10px; justify-content: flex-start; color: #344054; background: transparent; border: 0; border-radius: 6px; font-size: 13px; font-weight: 600; text-align: left; }
.smart-select-option:hover { color: #182230; background: #eef4ff; }
.smart-select-option.selected { color: #fff; background: var(--blue); }
.smart-select-option.selected:hover { color: #fff; background: var(--blue-dark); }
.smart-select-empty { padding: 12px 10px; color: var(--muted); font-size: 13px; text-align: center; }
.actions { display: flex; align-items: center; gap: 8px; }
button, .button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; color: #fff; background: var(--blue); border: 1px solid var(--blue); border-radius: 7px; cursor: pointer; text-decoration: none; font-weight: 700; transition: background .15s ease, border-color .15s ease, transform .08s ease; }
button:hover, .button:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
button:active, .button:active { transform: translateY(1px); }
button svg, .button svg { width: 17px; height: 17px; }
.button.secondary { color: #344054; background: #fff; border-color: #c8d3e1; }
.button.secondary:hover { background: #f8fafc; border-color: #98a2b3; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 18px 0 24px; }
.card { min-width: 0; min-height: 116px; padding: 18px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.card.accent { background: #eff6ff; border-color: #a9c9ff; box-shadow: inset 4px 0 var(--blue), var(--shadow); }
.card span { color: var(--muted); font-size: 13px; }
.card strong { display: block; margin-top: 13px; font-size: clamp(22px, 2.1vw, 29px); line-height: 1.05; overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid #e4eaf1; }
th { color: #667085; background: #f8fafc; font-size: 11px; font-weight: 800; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fbff; }
.empty { padding: 14px 0; color: var(--muted); }
.order-explorer { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(330px, .75fr); gap: 16px; }
.order-list { min-width: 0; overflow-x: auto; border: 1px solid var(--border); border-radius: 7px; }
.order-list tbody tr { cursor: pointer; }
.order-list tbody tr.active td { color: #fff; background: #2457bd; font-weight: 750; }
.order-list tbody tr.active:hover td { background: #1d4b9f; }
.order-list tbody tr:focus { outline: 2px solid #60a5fa; outline-offset: -2px; }
.order-detail, .table-products { min-width: 0; overflow: auto; align-self: start; border: 1px solid var(--border); border-radius: 7px; }
.order-detail table th, .order-detail table td, .table-products table th, .table-products table td { white-space: normal; }
.detail-head { min-height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: #f8fafc; border-bottom: 1px solid var(--border); }
.detail-head span { font-weight: 750; }
.detail-head strong { color: var(--blue); text-align: right; }
.detail-empty { margin: 0; padding: 14px; }
.clyo-order-view table th { color: #fff; background: #2563a9; border-right: 1px solid rgba(255,255,255,.2); }
.clyo-order-view table td { min-height: 34px; border-right: 1px solid #e5e7eb; }
.clyo-detail-grid { min-height: 320px; background: #fff; }
.clyo-detail-grid table { width: 720px; min-width: 720px; table-layout: fixed; }
.clyo-detail-grid th { white-space: nowrap; }
.clyo-detail-grid th:nth-child(1), .clyo-detail-grid td:nth-child(1) { width: 64px; text-align: center; }
.clyo-detail-grid th:nth-child(2), .clyo-detail-grid td:nth-child(2) { width: 250px; overflow-wrap: anywhere; }
.clyo-detail-grid th:nth-child(3), .clyo-detail-grid td:nth-child(3) { width: 126px; text-align: right; white-space: nowrap; }
.clyo-detail-grid th:nth-child(4), .clyo-detail-grid td:nth-child(4) { width: 180px; overflow-wrap: anywhere; }
.clyo-detail-grid th:nth-child(5), .clyo-detail-grid td:nth-child(5) { width: 100px; text-align: center; white-space: nowrap; }
.table-summary { display: inline-flex; align-items: baseline; gap: 9px; margin-bottom: 15px; padding: 10px 13px; background: #eff6ff; border: 1px solid #b9d5ff; border-radius: 7px; }
.table-summary strong { color: var(--blue-dark); font-size: 24px; }
.table-summary span { color: #344054; font-weight: 750; }
.table-manager { display: grid; grid-template-columns: minmax(220px, .42fr) minmax(0, 1fr); gap: 16px; }
.table-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-self: start; }
.table-tile { min-width: 0; min-height: 100px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 7px; text-align: left; }
.table-tile span { font-weight: 800; }
.table-tile strong { font-size: 18px; }
.table-tile small { color: var(--muted); }
.table-tile:hover { color: var(--text); background: #f8fbff; border-color: #93b4ee; }
.table-tile.active, .table-tile.active:hover { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 8px 18px rgba(37, 99, 235, .18); }
.table-tile.active small { color: #dbeafe; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-box { min-width: 0; padding: 14px; background: #f8fafc; border: 1px solid var(--border); border-radius: 7px; }
.stat-box span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.stat-box strong { display: block; margin-top: 8px; font-size: 20px; overflow-wrap: anywhere; }
.stats-columns { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); gap: 16px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.pager button { min-width: 86px; min-height: 36px; padding: 7px 11px; }
.pager button:disabled { opacity: .42; cursor: not-allowed; }
.pager span { color: var(--muted); font-size: 12px; font-weight: 750; }

html[data-theme="dark"] {
    --text: #e5edf7;
    --muted: #98a7ba;
    --bg: #0f1724;
    --card: #172231;
    --border: #304054;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 26px rgba(0, 0, 0, .16);
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }
html[dir="rtl"] body { font-family: Tahoma, Arial, sans-serif; }
html[dir="rtl"] .topbar-brand,
html[dir="rtl"] .brand,
html[dir="rtl"] .sidebar a,
html[dir="rtl"] .actions { direction: rtl; }
html[dir="rtl"] .menu-close { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .sidebar a.active { box-shadow: inset -3px 0 #5eead4; }
html[dir="rtl"] th,
html[dir="rtl"] td,
html[dir="rtl"] .smart-select-trigger,
html[dir="rtl"] .smart-select-option,
html[dir="rtl"] .table-tile { text-align: right; }
html[dir="rtl"] .smart-select-trigger { padding: 9px 12px 9px 38px; }
html[dir="rtl"] .smart-select-trigger::after { right: auto; left: 14px; }
html[dir="rtl"] .card.accent { box-shadow: inset -4px 0 var(--blue), var(--shadow); }
html[dir="rtl"] .detail-head strong { text-align: left; }
html[data-theme="dark"] .panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .table-tile,
html[data-theme="dark"] .order-detail,
html[data-theme="dark"] .table-products,
html[data-theme="dark"] .clyo-detail-grid { background: var(--card); border-color: var(--border); }
html[data-theme="dark"] .card.accent { background: #182d4a; border-color: #355f9f; }
html[data-theme="dark"] input,
html[data-theme="dark"] select { color: var(--text); background: #111c2a; border-color: #405168; }
html[data-theme="dark"] input::placeholder { color: #718096; }
html[data-theme="dark"] .smart-select-trigger,
html[data-theme="dark"] .smart-select-trigger:hover,
html[data-theme="dark"] .smart-select-menu { color: var(--text); background: #111c2a; border-color: #405168; }
html[data-theme="dark"] .smart-select-option { color: #dbe5f1; }
html[data-theme="dark"] .smart-select-option:hover { color: #fff; background: #26364a; }
html[data-theme="dark"] .smart-select-option.selected,
html[data-theme="dark"] .smart-select-option.selected:hover { color: #fff; background: #285fc7; }
html[data-theme="dark"] label { color: #a9b7c9; }
html[data-theme="dark"] .quick-periods { background: #111c2a; border-color: #405168; }
html[data-theme="dark"] .period-chip { color: #b8c5d5; }
html[data-theme="dark"] .period-chip:hover { color: #fff; background: #26364a; }
html[data-theme="dark"] .period-chip.active { color: #fff; background: #285fc7; }
html[data-theme="dark"] th { color: #aebacc; background: #1e2b3c; }
html[data-theme="dark"] th,
html[data-theme="dark"] td { border-color: #304054; }
html[data-theme="dark"] tbody tr:hover td { background: #1b2a3d; }
html[data-theme="dark"] .detail-head { background: #1e2b3c; border-color: var(--border); }
html[data-theme="dark"] .button.secondary { color: #dbe5f1; background: #1b2838; border-color: #405168; }
html[data-theme="dark"] .button.secondary:hover { background: #26364a; border-color: #52647c; }
html[data-theme="dark"] .table-summary { background: #182d4a; border-color: #355f9f; }
html[data-theme="dark"] .table-summary span { color: #dbe5f1; }
html[data-theme="dark"] .table-summary strong { color: #7eb0ff; }
html[data-theme="dark"] .table-tile { color: var(--text); }
html[data-theme="dark"] .table-tile:hover { color: #fff; background: #1d2d42; border-color: #5273a2; }
html[data-theme="dark"] .table-tile.active,
html[data-theme="dark"] .table-tile.active:hover { background: #285fc7; border-color: #3974e3; }
html[data-theme="dark"] .stat-box { background: #1b2838; border-color: var(--border); }
html[data-theme="dark"] .notice { color: #fdba74; background: #382517; border-color: #7c4a22; }
html[data-theme="dark"] .clyo-order-view table td { border-right-color: #304054; }
@media (max-width: 1120px) {
    .app-shell { grid-template-columns: 220px minmax(0, 1fr); gap: 18px; padding: 18px; }
    .filters form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters .actions { grid-column: 1 / -1; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .order-explorer { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .topbar { min-height: 64px; padding: 10px 14px; }
    .menu-toggle, .menu-close { display: inline-flex; }
    .topbar-mark { display: none; }
    .app-shell { display: block; padding: 14px; }
    .sidebar { position: fixed; z-index: 1001; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100dvh; top: 0; border-radius: 0 8px 8px 0; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 18px 0 48px rgba(16, 24, 40, .3); }
    .sidebar.open { transform: translateX(0); }
    html[dir="rtl"] .sidebar { inset: 0 0 0 auto; border-radius: 8px 0 0 8px; transform: translateX(105%); }
    html[dir="rtl"] .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; z-index: 1000; inset: 0; display: block; background: rgba(5, 12, 24, .56); backdrop-filter: blur(2px); }
    .sidebar-backdrop[hidden] { display: none; }
    .brand { padding-right: 12px; }
    .sidebar a { min-height: 48px; }
    .panel { margin-top: 14px; padding: 16px; }
    .table-manager, .stats-columns { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
    .topbar-brand h1 { font-size: 18px; }
    .topbar-brand p { display: none; }
    .topbar .status { padding: 7px 9px; }
    .topbar .status span { display: none; }
    .app-shell { padding: 10px; }
    .filters form { grid-template-columns: 1fr; gap: 10px; }
    .quick-periods { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; overflow: visible; }
    .period-chip { width: 100%; padding-inline: 8px; }
    .actions { display: grid; grid-template-columns: 1fr 1fr; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 10px; }
    .card { min-height: 102px; padding: 14px; }
    .card span { font-size: 12px; }
    .card strong { margin-top: 10px; font-size: 21px; }
    .panel { padding: 13px; border-radius: 7px; }
    h2 { font-size: 16px; }
    th, td { padding: 10px 8px; font-size: 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .table-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .table-tile { min-height: 92px; padding: 12px; }
    .detail-head { align-items: flex-start; flex-direction: column; gap: 4px; }
    .detail-head strong { text-align: left; }
    .clyo-detail-grid { min-height: 240px; overflow-x: auto; }
    .clyo-detail-grid table { width: 680px; min-width: 680px; }
    .pager { justify-content: space-between; }
}
@media (max-width: 390px) {
    .cards, .stats-grid { grid-template-columns: 1fr; }
    .table-list { grid-template-columns: 1fr; }
}
