:root {
  color-scheme: light;
  --navy: #0d1838;
  --blue: #2859b6;
  --blue-2: #3b6bc8;
  --blue-soft: #eef4ff;
  --orange: #f3a000;
  --green: #159566;
  --red: #c63d4d;
  --ink: #17213b;
  --muted: #68728a;
  --line: #dfe5f0;
  --surface: #ffffff;
  --canvas: #f4f7fc;
  --shadow: 0 18px 50px rgba(15, 31, 69, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 16px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(40, 89, 182, .28); outline-offset: 2px; }
[hidden] { display: none !important; }

.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.08fr) minmax(420px, .92fr); background: #fff; }
.login-brand { position: relative; overflow: hidden; padding: 54px clamp(42px, 6vw, 92px); display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: radial-gradient(circle at 78% 18%, rgba(74, 128, 236, .8), transparent 32%), linear-gradient(145deg, #101d45, #254fa4 62%, #3568ca); }
.login-brand::before, .login-brand::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.13); border-radius: 38px; transform: rotate(26deg); }
.login-brand::before { width: 420px; height: 420px; right: -130px; bottom: 20px; }
.login-brand::after { width: 260px; height: 260px; right: 30px; bottom: -100px; }
.login-logo { position: relative; z-index: 1; width: min(250px, 58%); padding: 10px 14px; border-radius: 14px; background: #fff; object-fit: contain; }
.login-brand-copy { position: relative; z-index: 1; max-width: 640px; margin: 90px 0; }
.eyebrow { display: inline-block; color: var(--orange); font-size: .78rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.login-brand h1 { margin: 18px 0 22px; max-width: 680px; font-size: clamp(2.7rem, 5vw, 5.6rem); line-height: .98; letter-spacing: -.055em; }
.login-brand p { max-width: 570px; color: rgba(255,255,255,.77); font-size: 1.12rem; line-height: 1.7; }
.security-note { position: relative; z-index: 1; display: flex; gap: 14px; align-items: center; width: fit-content; max-width: 500px; padding: 16px 20px; border: 1px solid rgba(255,255,255,.18); border-radius: 16px; background: rgba(255,255,255,.08); backdrop-filter: blur(12px); }
.security-icon { display: grid; place-items: center; flex: 0 0 34px; height: 34px; border-radius: 50%; background: rgba(68, 218, 158, .2); color: #78f2be; font-weight: 900; }
.security-note div { display: grid; gap: 3px; }
.security-note small { color: rgba(255,255,255,.66); line-height: 1.35; }
.login-panel { display: grid; place-items: center; padding: 44px; }
.login-card { width: min(440px, 100%); }
.mobile-logo { display: none; width: 210px; margin-bottom: 42px; }
.login-card h2 { margin: 12px 0 8px; font-size: 2rem; letter-spacing: -.025em; }
.muted { color: var(--muted); line-height: 1.55; }
.login-card > label { display: grid; gap: 8px; margin-top: 22px; font-weight: 700; font-size: .9rem; }
input, select, textarea { width: 100%; min-height: 48px; padding: 11px 13px; border: 1px solid #cfd7e6; border-radius: 11px; background: #fff; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #9daac1; }
.primary-button, .secondary-button, .danger-button { min-height: 42px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 800; }
.primary-button { color: #fff; background: var(--blue); box-shadow: 0 7px 18px rgba(40,89,182,.18); }
.primary-button:hover { background: #1f4a9f; }
.secondary-button { color: var(--ink); background: #fff; border-color: var(--line); }
.secondary-button:hover { background: #f7f9fd; }
.danger-button { color: #fff; background: var(--red); }
.login-card .primary-button { width: 100%; min-height: 52px; margin-top: 24px; }
.privacy-copy { display: block; margin-top: 18px; text-align: center; color: #8790a3; line-height: 1.45; }
.form-error { margin: 14px 0 0; padding: 11px 13px; border-radius: 9px; color: #9c2838; background: #fff0f2; font-size: .9rem; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 17px; color: #dce6ff; background: linear-gradient(180deg, #101a3d, #172b60); z-index: 10; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 4px 22px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand img { width: 154px; padding: 7px 9px; border-radius: 10px; background: #fff; object-fit: contain; }
.sidebar-brand span { padding-left: 12px; border-left: 1px solid rgba(255,255,255,.26); color: #f5b638; font-weight: 900; font-size: .82rem; letter-spacing: .12em; }
#main-nav { display: grid; gap: 5px; margin-top: 23px; overflow-y: auto; }
#main-nav button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 13px; border: 0; border-radius: 10px; color: #bfccee; background: transparent; text-align: left; font-weight: 650; font-size: .91rem; }
#main-nav button span { width: 20px; text-align: center; font-size: 1.1rem; }
#main-nav button:hover { color: var(--orange); background: rgba(255,255,255,.08); }
#main-nav button.active { color: #fff; background: linear-gradient(100deg, rgba(64,111,215,.58), rgba(64,111,215,.22)); box-shadow: inset 3px 0 var(--orange); }
.nav-label { margin: 17px 13px 4px; color: #7686ae; font-size: .68rem; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.sidebar-footer { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 14px 11px 0; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer div { display: grid; gap: 2px; }
.sidebar-footer strong { font-size: .8rem; }
.sidebar-footer small { color: #8192bb; font-size: .7rem; }
.system-dot { width: 9px; height: 9px; border-radius: 50%; background: #44d49a; box-shadow: 0 0 0 5px rgba(68,212,154,.12); }
.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 8; min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 14px clamp(22px, 3vw, 44px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.topbar p { margin: 0 0 3px; color: var(--blue); font-size: .7rem; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 1.42rem; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; font-size: 1.15rem; }
.account { display: flex; align-items: center; gap: 10px; margin-left: 4px; }
.account > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: #fff; background: linear-gradient(145deg, var(--blue), #4975cf); font-weight: 900; font-size: .8rem; }
.account div { display: grid; gap: 1px; }
.account strong { font-size: .82rem; }
.account small { color: var(--muted); font-size: .7rem; text-transform: capitalize; }
.menu-toggle { display: none; }
.content { padding: clamp(24px, 3.2vw, 48px); }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 24px; }
.page-heading h2 { margin: 0 0 6px; font-size: clamp(1.45rem, 2vw, 2rem); letter-spacing: -.035em; }
.page-heading p { margin: 0; color: var(--muted); line-height: 1.5; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card, .panel { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 7px 30px rgba(22,40,83,.045); }
.stat-card { padding: 21px; }
.stat-card header { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; font-weight: 750; }
.stat-card .stat-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--blue); background: var(--blue-soft); font-size: 1rem; }
.stat-card strong { display: block; margin-top: 16px; font-size: 2rem; letter-spacing: -.04em; }
.stat-card small { display: block; margin-top: 4px; color: var(--muted); }
.panel { overflow: hidden; }
.panel + .panel { margin-top: 18px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 19px 21px; border-bottom: 1px solid var(--line); }
.panel-header h3 { margin: 0; font-size: 1rem; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 18px; border-bottom: 1px solid #edf0f6; text-align: left; vertical-align: middle; }
th { color: #717c91; background: #fafbfe; font-size: .7rem; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
td { font-size: .88rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcff; }
.cell-title { display: grid; gap: 3px; }
.cell-title strong { font-size: .88rem; }
.cell-title small, td small { color: var(--muted); }
.number { font-variant-numeric: tabular-nums; font-weight: 750; }
.status { display: inline-flex; align-items: center; gap: 6px; min-height: 27px; padding: 4px 9px; border-radius: 999px; font-size: .72rem; font-weight: 850; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.pending, .status.disabled { color: #8a6720; background: #fff7df; }
.status.allocated, .status.connected { color: #17689f; background: #e8f5ff; }
.status.picking { color: #6b4ab2; background: #f2edff; }
.status.packed { color: #2457b8; background: #ebf1ff; }
.status.shipped, .status.active { color: #087955; background: #e8f8f1; }
.status.cancelled, .status.error { color: #a92e3e; background: #fff0f2; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.small-button { min-height: 32px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--blue); background: #fff; font-size: .75rem; font-weight: 800; }
.small-button:hover { background: var(--blue-soft); }
.split-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; }
.order-progress { display: flex; align-items: center; gap: 5px; min-width: 220px; }
.order-progress span { flex: 1; height: 5px; border-radius: 5px; background: #e8ecf4; }
.order-progress span.done { background: var(--blue); }
.channel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 18px; }
.channel-card { min-height: 132px; display: grid; align-content: space-between; gap: 20px; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.channel-card header { display: flex; justify-content: space-between; gap: 12px; }
.channel-card strong { text-transform: capitalize; }
.channel-card p { margin: 5px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.channel-card footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.empty-state { display: grid; place-items: center; min-height: 260px; padding: 40px; text-align: center; }
.empty-state span { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; color: var(--blue); background: var(--blue-soft); font-size: 1.4rem; }
.empty-state h3 { margin: 15px 0 7px; }
.empty-state p { max-width: 470px; margin: 0; color: var(--muted); line-height: 1.5; }
.empty-state button { margin-top: 18px; }
.loading-state { min-height: 55vh; display: grid; place-items: center; align-content: center; gap: 15px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid #dfe6f3; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

dialog { width: min(620px, calc(100% - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 18px; color: var(--ink); background: #fff; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 15, 35, .62); backdrop-filter: blur(4px); }
dialog form > header, dialog form > footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; }
dialog form > header { border-bottom: 1px solid var(--line); }
dialog form > footer { justify-content: flex-end; border-top: 1px solid var(--line); }
dialog h2 { margin: 5px 0 0; font-size: 1.25rem; }
.modal-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 22px; overflow-y: auto; }
.modal-body label { display: grid; align-content: start; gap: 7px; font-size: .82rem; font-weight: 800; }
.modal-body label.full, .modal-body .full { grid-column: 1 / -1; }
.modal-body small { color: var(--muted); font-weight: 500; line-height: 1.4; }
dialog .form-error { margin: 0 22px 18px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: grid; gap: 10px; }
.toast { width: min(360px, calc(100vw - 40px)); padding: 13px 15px; border-radius: 11px; color: #fff; background: #142451; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { background: #932c3a; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.banner { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; padding: 14px 16px; border: 1px solid #f2dba1; border-radius: 12px; color: #65490e; background: #fff9e9; line-height: 1.5; }
.banner strong { display: block; margin-bottom: 2px; }
.banner small { color: #7d642e; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .channel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; padding: 28px; }
  .mobile-logo { display: block; }
  .app-layout { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-102%); width: 260px; transition: transform .2s ease; box-shadow: 20px 0 45px rgba(9,17,40,.2); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .topbar { padding: 12px 18px; }
  .topbar-actions .account div, .topbar-actions .secondary-button { display: none; }
  .content { padding: 22px 16px 40px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .stats-grid, .channel-grid { grid-template-columns: 1fr; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-body label.full, .modal-body .full { grid-column: auto; }
  .topbar h1 { font-size: 1.1rem; }
  .topbar p { display: none; }
  .account > span { width: 34px; height: 34px; }
  th, td { padding: 12px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
