/* REPHON interface refresh. Screen only; no workflow or print-layout changes. */
:root {
  --bg: #10171c;
  --bg-soft: #151e25;
  --surface: #19242c;
  --surface-2: #202e38;
  --surface-3: #283844;
  --border: #344550;
  --border-strong: #536775;
  --text: #f0f5f8;
  --text-soft: #d0dce5;
  --text-muted: #a9bbc8;
  --primary: #65d8ab;
  --primary-hover: #8be7c1;
  --primary-soft: #213e35;
  --link: #90e8bf;
  --link-hover: #b4f4d6;
  --danger: #ff9ba6;
  --success: #82dfaf;
  --warning: #f3ca76;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --shadow-sm: 0 2px 5px rgb(0 0 0 / 12%);
  --shadow-md: 0 6px 20px rgb(0 0 0 / 18%);
  --shadow-lg: 0 16px 40px rgb(0 0 0 / 25%);
  --control-fill: #23333e;
  --action-bg: #18724e;
  --action-hover: #1c8259;
}

:root[data-theme="light"] {
  --bg: #f1f4f5;
  --bg-soft: #f6f8f9;
  --surface: #ffffff;
  --surface-2: #f4f7f8;
  --surface-3: #e8eef1;
  --border: #d5dfe4;
  --border-strong: #8b9ca8;
  --text: #182a35;
  --text-soft: #344c5b;
  --text-muted: #526977;
  --primary: #156c4a;
  --primary-hover: #105437;
  --primary-soft: #e4f3eb;
  --link: #126342;
  --link-hover: #0b492f;
  --danger: #ad293e;
  --success: #176b45;
  --warning: #81520b;
  --shadow-sm: 0 2px 5px rgb(24 42 53 / 4%);
  --shadow-md: 0 6px 20px rgb(24 42 53 / 8%);
  --shadow-lg: 0 16px 40px rgb(24 42 53 / 14%);
  --control-fill: #ffffff;
}

:root body.rephon-theme {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

:root body.rephon-theme h1 {
  font-size: clamp(27px, 2.6vw, 36px);
  line-height: 1.2;
  letter-spacing: -0.025em;
  font-weight: 700;
}

:root body.rephon-theme h2 {
  font-size: clamp(21px, 2vw, 26px);
  line-height: 1.3;
}

:root body.rephon-theme :is(.page-subtitle, .muted-note, .stat-label, .returns-metric-sub) {
  color: var(--text-muted);
  line-height: 1.55;
}

:root body.rephon-theme .top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
}

:root body.rephon-theme .top-inner {
  min-height: 68px;
  padding: 12px 24px;
}

:root body.rephon-theme .brand { font-size: 25px; letter-spacing: 0.045em; }
:root body.rephon-theme .wrap { padding-top: 24px; padding-bottom: 28px; }
:root body.rephon-theme .app-content { gap: 20px; }

:root body.rephon-theme :is(.top-menu-dropdown, .ui-modal-dialog) {
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}

:root body.rephon-theme .menu-section { background: var(--surface-2); border-color: var(--border); }
:root body.rephon-theme .menu-section h4 { color: var(--text-muted); font-size: 11px; }
:root body.rephon-theme .menu-link { color: var(--text); min-height: 40px; font-size: 14px; }
:root body.rephon-theme .menu-link.active { background: var(--primary-soft); color: var(--link); border-color: var(--primary); box-shadow: none; }

:root body.rephon-theme :is(.table-card, .settings-card, .auth-card, .stat-card,
  .receiving-panel, .receiving-search-panel, .returns-panel, .returns-metric-card,
  .home-quick-card, .orders-toolbar-card, .orders-utility-toolbar, .scanner-box) {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

:root body.rephon-theme :is(.settings-card, .table-card, .auth-card) > h2 { margin-bottom: 14px; }
:root body.rephon-theme :is(.settings-card, .auth-card) > p { margin-bottom: 16px; line-height: 1.6; }
:root body.rephon-theme .settings-content { display: grid; gap: 18px; }
:root body.rephon-theme .stat-card { padding: 22px; min-height: 130px; }
:root body.rephon-theme :is(.stat-value, .returns-metric-value) { color: var(--text); font-variant-numeric: tabular-nums; }
:root body.rephon-theme .home-hero { padding: clamp(22px, 4vw, 44px); }
:root body.rephon-theme .home-quick-card { padding: 22px; transition: border-color 120ms; }
:root body.rephon-theme .home-quick-card:hover { transform: none; border-color: var(--primary); }
:root body.rephon-theme .home-quick-title { color: var(--text); font-size: 18px; }
:root body.rephon-theme .home-quick-desc { color: var(--text-muted); line-height: 1.6; }

/* Controls keep their native semantics, sizes and event hooks. */
:root body.rephon-theme :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea) {
  background: var(--control-fill);
  color: var(--text);
  border-color: var(--border-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  box-shadow: none;
}
:root body.rephon-theme :is(input, textarea)::placeholder { color: var(--text-muted); opacity: 1; }
:root body.rephon-theme :is(input, select, textarea):focus {
  border-color: var(--primary);
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  box-shadow: none;
}
:root body.rephon-theme :is(input, select, textarea):disabled { opacity: 0.65; cursor: not-allowed; }
:root body.rephon-theme input[type="file"] { max-width: 100%; }
:root body.rephon-theme input::file-selector-button {
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 7px 10px; margin-right: 12px; font: inherit;
}
:root body.rephon-theme :is(button, .order-btn, .small-btn, .returns-btn, .orders-search-clear, .auth-link) {
  border-radius: 8px;
  font-weight: 600;
  line-height: 1.35;
  text-shadow: none;
  box-shadow: none;
  transition: background-color 120ms, border-color 120ms;
}
:root body.rephon-theme :is(button, .order-btn, .small-btn, .returns-btn-primary, .auth-link) {
  background: var(--action-bg);
  border-color: #24805c;
  color: #ffffff;
}
:root body.rephon-theme :is(button, .order-btn, .small-btn, .returns-btn-primary, .auth-link):hover {
  background: var(--action-hover); transform: none; box-shadow: none;
}
:root body.rephon-theme :is(.open-btn, .orders-search-clear, .returns-btn-secondary, .theme-toggle-btn,
  .menu-toggle-btn, .orders-view-btn, .orders-state-btn, .orders-filter-btn, .receiving-card-tab, .password-toggle) {
  background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border-strong); box-shadow: none;
}
:root body.rephon-theme :is(.open-btn, .orders-search-clear, .returns-btn-secondary, .theme-toggle-btn,
  .menu-toggle-btn, .orders-view-btn, .orders-state-btn, .orders-filter-btn, .receiving-card-tab, .password-toggle):hover {
  background: var(--surface-3); color: var(--text); border-color: var(--primary);
}
:root body.rephon-theme :is(.tab, .settings-tab) {
  background: var(--surface-2); color: var(--text-soft); border-color: var(--border); box-shadow: none;
}
:root body.rephon-theme :is(.tab, .settings-tab, .orders-view-btn, .orders-state-btn,
  .orders-filter-btn, .receiving-card-tab, .supplies-history-item).active {
  background: var(--primary-soft); color: var(--link); border-color: var(--primary); box-shadow: none;
}
:root body.rephon-theme :is(.danger-btn, .supplies-history-delete) {
  background: var(--surface); color: var(--danger); border-color: var(--danger);
}
:root body.rephon-theme :is(.danger-btn, .supplies-history-delete):hover {
  background: var(--surface-3); color: var(--danger);
}
:root body.rephon-theme :is(button, .order-btn, .small-btn):disabled {
  opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none;
}
:root body.rephon-theme :is(button, a, summary):focus-visible {
  outline: 2px solid var(--primary); outline-offset: 3px;
}
:root body.rephon-theme :is(.theme-toggle-btn, .auth-link, .menu-toggle-btn) { min-height: 40px; }
:root body.rephon-theme .user-badge { background: var(--surface-2); border-color: var(--border); color: var(--text-soft); box-shadow: none; }

/* Tables remain horizontally scrollable; no columns or data are hidden. */
:root body.rephon-theme :is(.orders-table, .supplies-table, .returns-table, .settings-history-table) {
  color: var(--text); font-size: 14px; line-height: 1.45; font-variant-numeric: tabular-nums;
}
:root body.rephon-theme :is(.orders-table, .supplies-table, .returns-table, .settings-history-table) th {
  background: var(--surface-2); color: var(--text-soft); border-color: var(--border);
  font-size: 12px; line-height: 1.4; font-weight: 700; letter-spacing: 0.035em; padding: 12px;
}
:root body.rephon-theme :is(.orders-table, .supplies-table, .returns-table, .settings-history-table) td {
  border-color: var(--border); padding: 12px; vertical-align: top;
}
:root body.rephon-theme :is(.orders-table, .supplies-table, .returns-table, .settings-history-table) tbody tr:hover {
  background: var(--surface-2);
}
:root body.rephon-theme :is(.supplies-history-item, .receiving-product-card, .returns-problem-item) {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}
:root body.rephon-theme .auth-card { width: min(100%, 460px); margin: 5vh auto; padding: 30px; }
:root body.rephon-theme .auth-form { gap: 12px; }
:root body.rephon-theme .auth-form > label { font-weight: 600; color: var(--text-soft); }
:root body.rephon-theme .auth-form > button { margin-top: 8px; min-height: 44px; }
:root body.rephon-theme .settings-card { min-width: 0; overflow-wrap: anywhere; }
:root body.rephon-theme .settings-card > * { min-width: 0; }
:root body.rephon-theme .settings-card code { overflow-wrap: anywhere; white-space: normal; }

/* Both order visual modes share legible colors, but retain their own layout. */
:root body.rephon-theme #ozonCutoffDateInput { min-width: 155px; }
:root body.rephon-theme #ordersToolbarSticky .orders-head-window-kicker { color: var(--link); }
:root[data-theme="light"] body.rephon-theme .orders-page-shell:is(.orders-visual-modern, .orders-visual-classic)
  :is(.meta-item, .group-meta > span, .group-order-meta > span) {
  color: var(--text-soft); opacity: 1;
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-modern, .orders-visual-classic)
  :is(.order-card-v2, .group-card, .group-order-row, #ordersToolbarSticky, .orders-utility-toolbar) {
  background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm);
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-modern, .orders-visual-classic) .order-card-v2:hover {
  transform: none; border-color: var(--primary); box-shadow: var(--shadow-sm);
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-modern, .orders-visual-classic)
  :is(.order-title-v2, .group-title, .group-order-title) {
  color: var(--text); font-size: 17px; line-height: 1.4; font-weight: 700;
  text-shadow: none; overflow-wrap: anywhere;
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-modern, .orders-visual-classic)
  :is(.meta-item, .group-meta > span, .group-order-meta > span) {
  color: var(--text-soft); background: var(--surface-2); border-color: var(--border);
  font-size: 13px; line-height: 1.5; text-shadow: none;
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-modern, .orders-visual-classic)
  :is(.meta-item-cell, .meta-item-sector, .meta-item-article) {
  color: var(--link); background: var(--primary-soft); font-weight: 700;
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-modern, .orders-visual-classic) .meta-item-qty {
  color: var(--warning); background: var(--surface-2); font-weight: 700;
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-modern, .orders-visual-classic)
  :is(.orders-control-kicker, .orders-select-label, .orders-print-agent-meta, .orders-search-count) {
  color: var(--text-soft); font-size: 13px; line-height: 1.4;
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-modern, .orders-visual-classic)
  :is(.orders-control-group, .orders-head-window-card, .orders-visual-mode-group) {
  background: var(--surface-2); border-color: var(--border); box-shadow: none;
}
:root body.rephon-theme .foot { color: var(--text-muted); padding: 18px; margin-top: 0; }

@media (max-width: 760px) {
  :root body.rephon-theme .wrap { padding: 16px 12px 24px; }
  :root body.rephon-theme .top-inner { padding: 10px 12px; gap: 10px; }
  :root body.rephon-theme .top-left { justify-content: space-between; width: 100%; }
  :root body.rephon-theme .top-right { margin-left: 0; justify-content: space-between; gap: 8px; }
  :root body.rephon-theme .auth-box { width: auto; flex: 1; justify-content: flex-end; }
  :root body.rephon-theme .theme-toggle-btn { flex: 0 0 auto; }
  :root body.rephon-theme .user-badge { font-size: 12px; padding: 6px 8px; }
  :root body.rephon-theme .auth-card { padding: 22px; margin: 20px auto; }
  :root body.rephon-theme :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea) {
    font-size: 16px;
  }
  :root body.rephon-theme :is(.home-quick-grid, .dashboard-grid) { grid-template-columns: minmax(0, 1fr); }
}

/* Editorial hierarchy and aligned work surfaces; no behavioral overrides. */
:root body.rephon-theme {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
:root body.rephon-theme :is(button, input, select, textarea) { font-family: inherit; }
:root body.rephon-theme .top { border-top: 3px solid var(--primary); }
:root body.rephon-theme .brand { font-weight: 800; letter-spacing: -0.04em; }
:root body.rephon-theme h1 { letter-spacing: -0.04em; margin-bottom: 10px; }
:root body.rephon-theme :is(.table-card, .settings-card, .receiving-panel, .returns-panel) { border-radius: 16px; }
:root body.rephon-theme :is(.home-quick-card, .stat-card) {
  border-top: 3px solid var(--primary); box-shadow: var(--shadow-sm);
}
:root body.rephon-theme .menu-section { border: 0; border-radius: 12px; padding: 12px; }
:root body.rephon-theme .menu-link { border-radius: 8px; }
:root body.rephon-theme :is(.orders-control-kicker, .orders-head-window-kicker) {
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em; line-height: 1.5;
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-classic, .orders-visual-modern) #ordersToolbarSticky {
  padding: 16px; border-radius: 16px;
}
:root body.rephon-theme #ordersToolbarSticky .orders-toolbar-state-row {
  display: flex; flex-wrap: wrap; align-items: stretch; gap: 16px;
}
:root body.rephon-theme #ordersToolbarSticky .orders-control-group {
  padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
}
:root body.rephon-theme #ordersToolbarSticky :is(.orders-state-tabs, .orders-view-tabs) {
  padding: 4px; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
:root body.rephon-theme #ordersToolbarSticky :is(.orders-state-btn, .orders-view-btn) {
  min-height: 36px; padding: 8px 12px; border: 1px solid transparent; background: transparent;
  color: var(--text-soft); box-shadow: none;
}
:root body.rephon-theme #ordersToolbarSticky :is(.orders-state-btn, .orders-view-btn).active {
  background: var(--primary-soft); border-color: var(--primary); color: var(--link);
}
:root body.rephon-theme #ordersToolbarSticky .orders-head-window-form { flex: 1 1 640px; min-width: 0; }
:root body.rephon-theme #ordersToolbarSticky .orders-head-window-card {
  display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 12px;
  border-radius: 12px; background: var(--surface-2);
}
:root body.rephon-theme #ordersToolbarSticky .orders-head-window-copy { flex: 1 1 180px; }
:root body.rephon-theme #ordersToolbarSticky .orders-head-window-fields { display: flex; gap: 8px; flex: 0 1 auto; }
:root body.rephon-theme #ordersToolbarSticky .orders-head-window-actions { display: flex; flex-wrap: wrap; gap: 8px; }
:root body.rephon-theme #ordersToolbarSticky .orders-search-row { margin-top: 16px; gap: 10px; }
:root body.rephon-theme #ordersToolbarSticky .orders-server-filters {
  display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding-top: 16px; margin-top: 16px;
}
:root body.rephon-theme #ordersToolbarSticky .orders-filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }
:root body.rephon-theme #ordersToolbarSticky :is(.orders-search-input, .orders-search-clear) {
  min-height: 42px; border-radius: 9px;
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-classic, .orders-visual-modern) .order-card-v2 {
  border-radius: 16px; padding: 16px; gap: 16px;
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-classic, .orders-visual-modern) .meta-item {
  font-weight: 500; border-radius: 6px; padding: 4px 8px;
}
:root body.rephon-theme .orders-page-shell:is(.orders-visual-classic, .orders-visual-modern) .meta-item-article { font-weight: 700; }
@media (max-width: 760px) {
  :root body.rephon-theme .top-right { display: flex; flex-direction: row; flex-wrap: wrap; width: 100%; }
  :root body.rephon-theme .auth-box { min-width: 0; flex-wrap: wrap; }
  :root body.rephon-theme #ordersToolbarSticky .orders-control-group { flex: 1 1 100%; }
  :root body.rephon-theme #ordersToolbarSticky :is(.orders-state-tabs, .orders-view-tabs) { display: flex; flex-wrap: wrap; }
  :root body.rephon-theme #ordersToolbarSticky :is(.orders-state-btn, .orders-view-btn) { flex: 1 1 auto; }
  :root body.rephon-theme #ordersToolbarSticky .orders-head-window-copy { flex-basis: 100%; }
  :root body.rephon-theme #ordersToolbarSticky .orders-head-window-fields { width: 100%; flex-wrap: wrap; }
  :root body.rephon-theme #ordersToolbarSticky .orders-head-window-field { min-width: 0; flex: 1 0 100px; }
  :root body.rephon-theme #ordersToolbarSticky .orders-head-window-field:first-child { flex-basis: 155px; }
  :root body.rephon-theme #ordersToolbarSticky .orders-head-window-actions { width: 100%; }
  :root body.rephon-theme #ordersToolbarSticky .orders-head-window-actions > * { flex: 1 1 auto; }
  :root body.rephon-theme #ordersToolbarSticky .orders-filter-field { flex: 1 1 140px; min-width: 0; }
}

/* A tall pinned toolbar must not cover the orders on handheld screens. */
@media (max-width: 760px), (max-height: 650px) {
  :root body.rephon-theme .orders-page-shell:is(.orders-visual-modern, .orders-visual-classic) #ordersToolbarSticky {
    position: static;
    top: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root body.rephon-theme :is(button, a, .order-card-v2, .ui-modal-dialog) {
    transition: none; animation: none;
  }
}
