@import url('ops-variables.css');

/* ===== RESET & BASE ===== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--font-ar);
  font-size: var(--text-lg);
  line-height: 1.6;
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  direction: ltr;
  display: inline-block;
  unicode-bidi: embed;
}

/* ===== HEADER & NAVIGATION ===== */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: calc(100% - var(--sidebar-width));
  margin-right: var(--sidebar-width);
  min-height: var(--header-height);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--c-shell);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

header h1 {
  min-width: 130px;
  margin: 0;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
}

header h1 small {
  display: block;
  margin-top: 2px;
  color: var(--c-shell-muted);
  font-size: 9px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

header nav {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 72px 10px var(--space-lg);
  background: linear-gradient(180deg, var(--c-shell), #072a32);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: -6px 0 20px rgba(12, 39, 46, 0.05);
  z-index: 99999;
  overflow-y: auto;
  scrollbar-width: none;
}

header nav::-webkit-scrollbar {
  display: none;
}

header nav::before {
  content: "ADOPS";
  position: absolute;
  top: 20px;
  right: 16px;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.8px;
}

header nav::after {
  content: "E-COMMERCE OPERATIONS";
  position: absolute;
  top: 42px;
  right: 16px;
  color: var(--c-shell-muted);
  font-size: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.ops-nav-group {
  display: block;
  margin: 14px 6px 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--c-shell-muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ops-nav-group:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.admin-nav-links {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.admin-nav-links[hidden],
header nav a[hidden] {
  display: none !important;
}

header nav a {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--c-shell-text);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 700;
  transition: var(--transition-base);
}

header nav a::before {
  content: "";
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: #8faeb5;
  font-family: Arial, sans-serif;
  font-size: 14px;
}

header nav a[href="/ui/"]::before { content: "⌂"; }
header nav a[href="/ui/products.html"]::before { content: "▦"; }
header nav a[href="/ui/employee.html"]::before { content: "⌂"; }
header nav a[href="/ui/ops.html"]::before { content: "▣"; }

header nav a:hover {
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
}

header nav a:hover::before {
  background: rgba(84, 211, 170, 0.11);
  color: #67ddb8;
}

header nav a[aria-current="page"] {
  background: linear-gradient(90deg, rgba(32, 126, 108, 0.3), rgba(25, 102, 92, 0.18));
  border-color: rgba(84, 211, 170, 0.22);
  color: #65ddb7;
  box-shadow: inset -3px 0 0 var(--c-accent);
}

header nav a[aria-current="page"]::before {
  background: rgba(84, 211, 170, 0.14);
  color: #65ddb7;
}

/* Controls */
header .controls {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

#currentuser {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: rgba(84, 211, 170, 0.08);
  border: 1px solid rgba(84, 211, 170, 0.16);
  color: #77dcbf;
  font-size: 10px;
  font-weight: 800;
}

#logout {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--c-ink);
  font-weight: 800;
  font-size: 11px;
  cursor: pointer;
  transition: var(--transition-fast);
}

#logout:hover {
  background: #f5f8f9;
}

#apikey {
  height: 30px;
  width: 120px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-md);
  background: #0a2932;
  color: #eaf2f3;
  font-family: var(--font-mono);
  font-size: 11px;
}

#mode {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  background: rgba(84, 211, 170, 0.07);
  border: 1px solid rgba(84, 211, 170, 0.18);
  color: #74d9b9;
  font-size: 10px;
  padding: 0 10px;
}

/* ===== MAIN LAYOUT ===== */
main {
  margin-right: var(--sidebar-width);
  max-width: none;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

main > #employeeDashboard,
main > #authwarn,
main > #err {
  grid-column: 1 / -1;
}

main > section.card {
  grid-column: 1 / -1;
}

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.card > h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  padding: 13px 16px;
  background: linear-gradient(180deg, #fafbfc 0%, #f5f8f9 100%);
  border-bottom: 1px solid #e3eaec;
  color: var(--c-ink);
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.card > h2 .hint {
  font-size: 10px;
  font-weight: 500;
  color: #7a8c93;
  margin-inline-start: var(--space-sm);
}

.pad {
  padding: 16px;
}

/* ===== NEW ORDER FORM ===== */
#orderform {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  max-width: 600px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(16, 42, 51, 0.045);
}

#orderform.collapsed {
  max-width: none;
  margin: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

#orderform.collapsed .pad {
  display: none;
}

#orderform.collapsed h2 {
  cursor: pointer;
  user-select: none;
}

#orderform.collapsed h2::after {
  content: "▼";
  margin-inline-start: auto;
  font-size: 12px;
  color: var(--c-accent);
}

#orderform:not(.collapsed) h2::after {
  content: "▲";
  margin-inline-start: auto;
  font-size: 12px;
  color: var(--c-muted);
  cursor: pointer;
}

form.new-order {
  background: var(--c-surface);
}

.field {
  margin-bottom: 10px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  color: #74868d;
  font-size: 10px;
  font-weight: 700;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 14px;
  font-size: 13px;
}

.checkline input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.discussion-list {
  display: grid;
  gap: 7px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.discussion-entry {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,.035);
  overflow-wrap: anywhere;
  font-size: 12px;
}

.discussion-entry small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

#cod.bad,
#edcod.bad {
  color: var(--danger, #b42318);
}

.field input,
.field select,
.field textarea,
.lines select,
.lines input {
  min-height: 38px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #dae3e5;
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--c-ink);
  font: inherit;
  font-family: var(--font-ar);
  font-size: var(--text-sm);
  transition: all 0.2s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.lines select:focus,
.lines input:focus {
  outline: none;
  background: #fff;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(22, 128, 93, 0.08);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lines {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  background: #fafbfa;
  display: grid;
  gap: 10px;
}

.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px 85px 28px;
  gap: 8px;
  align-items: center;
}

.line select,
.line input {
  font-size: var(--text-sm);
  padding: 5px 6px;
  min-height: 34px;
}

.line .rm {
  background: transparent;
  border: 1px solid var(--c-border-light);
  color: var(--c-danger);
  padding: 4px 0;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

button.mini {
  min-height: 34px;
  border-radius: var(--radius-md);
  border: 1px dashed #bfd1d5;
  background: #f7fafb;
  color: #315d67;
  font-weight: 700;
  font-size: 11px;
  cursor: pointer;
  transition: var(--transition-fast);
}

button.mini:hover {
  background: #eff5f7;
}

.total {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #deebe7;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #f3faf7, #f8fbfa);
  display: flex;
  justify-content: space-between;
  font-size: var(--text-md);
}

.total b {
  color: #137457;
  font-size: 20px;
  font-family: var(--font-mono);
}

#save,
button.primary {
  min-height: 42px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--c-primary);
  color: #fff;
  font-weight: 700;
  font-size: var(--text-md);
  font-family: var(--font-ar);
  box-shadow: 0 2px 8px rgba(22, 128, 93, 0.18);
  cursor: pointer;
  transition: all 0.2s ease;
}

#save:hover,
button.primary:hover {
  background: var(--c-primary-dark);
  box-shadow: 0 4px 12px rgba(22, 128, 93, 0.28);
  transform: translateY(-1px);
}

#save:disabled,
button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
form.new-order {
  background: var(--c-surface);
}

/* ===== STATUS TABS ===== */
.tabs {
  display: flex;
  gap: 5px;
  padding: 9px 10px;
  overflow-x: auto;
  background: #f7fafb;
  border-bottom: 1px solid var(--c-border);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid #e0e8ea;
  border-radius: var(--radius-md);
  background: #fff;
  color: #60737a;
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
  font-family: var(--font-ar);
  cursor: pointer;
  transition: var(--transition-base);
}

.tabs button:hover {
  border-color: #bfd1d5;
  background: #fbfdfd;
}

.tabs button[aria-selected="true"] {
  border-color: #1e6f62;
  background: #123f49;
  color: #fff;
  box-shadow: 0 3px 10px rgba(18, 63, 73, 0.12);
}

.tabs .c {
  margin-inline-start: 5px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: #edf2f3;
  color: #567078;
  font-size: 9px;
  font-weight: 700;
}

.tabs button[aria-selected="true"] .c {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* ===== FILTERS ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid #e7edef;
}

.filters .f {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filters label {
  color: #788a91;
  font-size: 10px;
  font-weight: 700;
}

.filters select,
.filters input {
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid #dce6e8;
  border-radius: var(--radius-md);
  background: #fbfcfc;
  color: #17353e;
  font-family: var(--font-ar);
  font-size: var(--text-sm);
  transition: var(--transition-base);
}

.date-range-filter input[type="date"] {
  min-width: 130px;
  direction: ltr;
  text-align: center;
}

.filters select:focus,
.filters input:focus {
  outline: none;
  border-color: #54caa6;
  box-shadow: 0 0 0 3px rgba(84, 202, 166, 0.08);
}

.filters .clear {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #dfe7e9;
  border-radius: var(--radius-md);
  background: #fff;
  color: #667b82;
  font-weight: 700;
  font-size: var(--text-sm);
  font-family: var(--font-ar);
  cursor: pointer;
  transition: var(--transition-fast);
}

.filters .clear:hover {
  background: #f5f8f9;
}

.filters .hits {
  margin-inline-start: auto;
  padding: 5px 8px;
  border-radius: var(--radius-full);
  background: #f1f5f6;
  color: #60757c;
  font-size: 10px;
  font-family: var(--font-mono);
}

@media (max-width: 1180px) and (min-width: 901px) {
  .filters .f {
    flex: 1 1 150px;
  }
}

/* ===== BULK ACTIONS ===== */
.bulkbar {
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid #dce8e5;
  background: linear-gradient(90deg, #edf8f4, #f6fbf9);
  display: flex;
  align-items: center;
  font-size: var(--text-sm);
}

.bulkbar select {
  min-height: 34px;
  border: 1px solid #cfe1dc;
  border-radius: var(--radius-md);
  background: #fff;
  font-family: var(--font-ar);
  font-size: var(--text-sm);
}

.bulkbar button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 800;
  font-family: var(--font-ar);
  cursor: pointer;
  border: 0;
}

.bulkbar .ok {
  background: #17765b;
  color: #fff;
}

#bulkship {
  min-width: 150px;
}

.bulkbar .ok:hover {
  background: #126047;
}

.bulkbar .no {
  background: #fff;
  color: #9a4a42;
  border: 1px solid #edd3cf;
}

.bulkbar .no:hover {
  background: #fff5f3;
}

/* ===== ORDERS TABLE ===== */
.scroll {
  background: #fff;
  overflow: auto;
  max-height: calc(100vh - 240px);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
  min-width: 1100px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 38px;
  padding: 8px 10px;
  background: linear-gradient(180deg, #f1f6f6 0%, #e9f0f1 100%);
  color: #2d4a52;
  border-bottom: 2px solid #d5e0e2;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

tbody td {
  padding: 10px;
  border-bottom: 1px solid #eef3f4;
  vertical-align: middle;
  text-align: right;
  font-size: var(--text-sm);
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: #f9fcfc;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.n {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 800;
  direction: ltr;
  text-align: left;
  color: #123f49;
}

td.acts {
  min-width: 280px;
  max-width: 340px;
  white-space: normal;
  text-align: left;
}

/* ===== CHIPS & BADGES ===== */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  background: #e7ece9;
  color: var(--c-ink);
}

.chip.d {
  background: #e3f0ea;
  color: var(--c-primary);
  border: 1px solid #c8e6d8;
}

.chip.r {
  background: #f7e6e3;
  color: var(--c-danger);
  border: 1px solid #f5d5d1;
}

.chip.t {
  background: #faf0dc;
  color: #8a5f10;
  border: 1px solid #f2deb8;
}

.chip.x { background: #fff0d5; color: #8a4d00; border: 1px solid #e9c987; }
.carrier-status-line { display: block; color: var(--c-ink); font-size: 11px; margin-top: 4px; }
.jt-status-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px; border-bottom: 1px solid #dbe6e9; align-items: center; }
.jt-status-tabs button[aria-pressed="true"] { background: #147d69; color: white; }
.jt-status-tabs small { flex-basis: 100%; color: #526e77; }

/* ===== EMPTY STATE ===== */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: #839399;
  font-size: var(--text-md);
}

/* ===== ROW ACTIONS ===== */
td.acts button.act {
  min-height: 28px;
  margin: 2px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-ar);
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.15s ease;
}

td.acts button.act:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

button[data-act="delete-duplicate"] {
  background: #fff0ef;
  color: #a92832;
  border-color: #e8a0a4;
  font-weight: 800;
}

button[data-act="confirm"] {
  background: #177a5d;
  color: #fff;
  border-color: #177a5d;
}

button[data-act="confirm"]:hover {
  background: #12684f;
}

button[data-act="contacting"] {
  background: #eff8f5;
  color: #176b55;
  border-color: #cde7de;
}

button[data-act="contacting"]:hover {
  background: #e4f4ee;
}

button[data-act="callback"] {
  background: #fff8ee;
  color: #a16a19;
  border-color: #efddbe;
}

button[data-act="callback"]:hover {
  background: #fff2df;
}

button[data-act="edit"] {
  background: #fff;
  color: #536d75;
  border-color: #d7e2e5;
}

button[data-act="edit"]:hover {
  background: #f5f8f9;
}

button[data-act="cancel"] {
  background: #fff5f3;
  color: #b64a40;
  border-color: #edcfca;
}

button[data-act="cancel"]:hover {
  background: #ffebe8;
}

button[data-act="assign"],
button[data-act="reassign"] {
  background: #f2f7f8;
  color: #315e68;
  border-color: #d5e3e6;
}

button[data-act="ship"] {
  background: #24728a;
  color: #fff;
  border-color: #24728a;
}

button[data-act="ship"]:hover {
  background: #1f5f75;
}

.assignsel {
  min-height: 30px;
  max-width: 112px;
  margin: 2px;
  padding: 0 7px;
  border: 1px solid #d9e4e6;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #31545d;
  font-size: var(--text-xs);
  font-family: var(--font-ar);
  cursor: pointer;
}

.csel {
  min-height: 31px;
  max-width: 145px;
  padding: 0 7px;
  border: 1px solid #d8e4e6;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #31545d;
  font-size: var(--text-xs);
  font-family: var(--font-ar);
  cursor: pointer;
}

.pick {
  width: 15px;
  height: 15px;
  accent-color: #177a5d;
  cursor: pointer;
}

/* ===== DIALOGS ===== */
dialog {
  width: min(520px, calc(100vw - 24px));
  max-width: 520px;
  border: 1px solid #dfe7e9;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 24px 64px rgba(7, 31, 37, 0.22);
  overflow: hidden;
  font-family: var(--font-ar);
  color: var(--c-ink);
  padding: 0;
}

dialog::backdrop {
  background: rgba(6, 30, 37, 0.58);
  backdrop-filter: blur(2px);
}

dialog h3 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 800;
  padding: 12px 14px;
  background: #f7fafb;
  border-bottom: 1px solid #e4ebed;
  color: var(--c-ink);
  display: flex;
  gap: 6px;
  align-items: baseline;
}

dialog h3 .sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #788a91;
  font-weight: 400;
}

dialog .body {
  padding: 14px;
  max-height: 68vh;
  overflow: auto;
}

dialog .sect {
  margin: 14px 0 7px;
  padding-bottom: 5px;
  border-bottom: 1px solid #e8edef;
  color: #315b64;
  font-size: 10px;
  font-weight: 800;
}

dialog .sect:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

dialog .foot {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
  padding: 10px 14px;
  border-top: 1px solid #e4ebed;
  background: #f8fafb;
}

dialog .foot button {
  min-height: 36px;
  border-radius: var(--radius-md);
  font-family: var(--font-ar);
  cursor: pointer;
  border: 0;
}

dialog .foot .primary {
  width: auto;
  padding: 0 18px;
  background: linear-gradient(135deg, #59d7af, #42b990);
  color: #08241b;
  font-weight: 900;
  font-size: var(--text-sm);
}

dialog .foot .no {
  background: #fff;
  border: 1px solid #dde6e8;
  color: #687c83;
  font-weight: 700;
  font-size: var(--text-sm);
}

.locked {
  font-size: var(--text-sm);
  color: #7a5a12;
  background: #fdf6e6;
  border: 1px solid #e6d4a8;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
  line-height: 1.4;
}

.hintline {
  font-size: 10px;
  color: var(--c-muted);
  margin: -3px 0 10px;
  line-height: 1.4;
}

.costnow {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--c-muted);
}

/* ===== ALERTS & TOASTS ===== */
.banner {
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: 12px;
  border: 1px solid;
  grid-column: 1 / -1;
}

.banner.warn {
  background: #fdf6e6;
  border-color: #e6d4a8;
  color: #7a5a12;
}

.banner.err {
  background: #fbeceb;
  border-color: #e8c3bf;
  color: var(--c-danger);
  max-height: 240px;
  overflow: auto;
  white-space: pre-line;
}

.banner.ok {
  background: #e9f3ee;
  border-color: #bcd9cb;
  color: var(--c-primary);
}

.banner b {
  font-weight: 600;
}

.toast {
  position: fixed;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  background: var(--c-ink);
  color: #eef3f1;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  z-index: 9;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.16);
  animation: slideUp 0.3s ease;
}

.toast.bad {
  background: #c7463b;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== EMPLOYEE DASHBOARD ===== */
#employeeDashboard[hidden] {
  display: none;
}

.bulk-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.bulk-actions[hidden] {
  display: none;
}

.employee-dashboard {
  grid-column: 1 / -1;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.mobile-order-head {
  display: none;
}

.empdash-head,
.targettop,
.targetfoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.empdash-head strong {
  font-size: 14px;
  font-weight: 800;
}

.empdash-head span {
  font-size: var(--text-sm);
  color: var(--c-muted);
  margin-inline-start: 10px;
}

.bonus-state {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: #e8ece9;
  font-weight: 700;
}

.empstats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.empstat {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 10px;
}

.empstat span {
  display: block;
  font-size: 10px;
  color: var(--c-muted);
}

.empstat b {
  font-size: 19px;
  margin-top: 2px;
  font-weight: 800;
}

.empstat.good b {
  color: var(--c-primary);
}

.empstat.bad b {
  color: var(--c-danger);
}

.targetbox {
  margin-top: 12px;
  padding: 11px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: #fafbfa;
}

.progress {
  height: 7px;
  background: #e7ece9;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 10px 0 6px;
}

.progress div {
  height: 100%;
  width: 0;
  background: var(--c-primary);
  border-radius: var(--radius-full);
  transition: width 0.25s ease;
}

/* ===== EMPLOYEE WALLET ===== */
.employee-wallet {
  margin-top: 12px;
  border: 1px solid #dbe5e1;
  border-radius: var(--radius-lg);
  background: #fff;
  overflow: hidden;
}

.wallet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid #e7eeeb;
  background: #f8fbf9;
}

.wallet-head > div {
  display: flex;
  align-items: center;
  gap: 7px;
}

.wallet-head strong {
  font-size: var(--text-md);
  color: var(--c-ink);
  font-weight: 800;
}

.wallet-head span {
  font-size: 10px;
  color: var(--c-muted);
}

.wallet-history-btn {
  border: 1px solid #ccdcd6;
  background: #fff;
  color: #315b50;
  border-radius: var(--radius-md);
  padding: 5px 9px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-ar);
  cursor: pointer;
}

.wallet-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wallet-stat {
  padding: 10px;
  border-inline-end: 1px solid #edf1ef;
}

.wallet-stat:last-child {
  border-inline-end: 0;
}

.wallet-stat span {
  display: block;
  color: var(--c-muted);
  font-size: 10px;
  margin-bottom: 2px;
}

.wallet-stat strong {
  display: block;
  color: var(--c-ink);
  font-size: 15px;
  font-weight: 800;
}

.wallet-earned strong {
  color: #b17608;
}

.wallet-paid strong {
  color: var(--c-primary);
}

.wallet-history {
  border-top: 1px solid #e7eeeb;
  padding: 8px 12px;
  background: #fcfdfc;
  max-height: 170px;
  overflow: auto;
}

.wallet-history-title {
  font-size: 10px;
  font-weight: 800;
  color: var(--c-muted);
  margin-bottom: 6px;
}

.wallet-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #edf1ef;
  font-size: var(--text-sm);
}

.wallet-history-row:last-child {
  border-bottom: 0;
}

.wallet-history-row .paid {
  color: var(--c-primary);
  font-weight: 800;
}

.wallet-history-row .earned {
  color: #a46d08;
  font-weight: 800;
}

/* ===== REWARD DASHBOARD ===== */
.reward-dashboard {
  border: 0;
  background: transparent;
  padding: 0;
  overflow: hidden;
}

.reward-main {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.6fr);
  gap: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid #d8e2de;
  background: #fff;
  box-shadow: 0 4px 14px rgba(18, 48, 58, 0.1);
}

.reward-info {
  padding: 20px 22px;
  background: radial-gradient(circle at 15% 20%, #fff4b8 0, transparent 30%), linear-gradient(135deg, #fffdf4, #f4faf7);
}

.reward-label {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #8a6512;
  background: #fff4cb;
  border: 1px solid #f0d67d;
  border-radius: var(--radius-full);
  padding: 3px 9px;
  margin-bottom: 6px;
}

.reward-title {
  color: var(--c-muted);
  font-size: var(--text-md);
}

.reward-money {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 1px;
  color: #9a6b00;
}

.reward-money span {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.1;
}

.reward-money small {
  font-size: 15px;
  font-weight: 700;
}

.reward-state {
  margin-top: 8px;
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: #e7f4ed;
  color: var(--c-primary);
}

.reward-counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: var(--c-ink);
  color: #fff;
  text-align: center;
  min-height: 170px;
  position: relative;
}

.reward-counter::before {
  content: "🎯";
  font-size: 26px;
  margin-bottom: 4px;
}

.counter-label {
  font-size: var(--text-sm);
  opacity: 0.75;
}

.counter-number {
  direction: ltr;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 7px 0;
}

.counter-number .num {
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
}

.counter-divider {
  opacity: 0.35;
  font-size: 30px;
}

.counter-caption {
  font-size: var(--text-sm);
  opacity: 0.7;
}

.reward-progress-wrap {
  background: #fff;
  border: 1px solid var(--c-border);
  border-top: 0;
  padding: 12px 16px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.reward-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
  margin-bottom: 6px;
}

.reward-progress-head strong {
  color: var(--c-ink);
  font-size: var(--text-md);
  font-weight: 800;
}

.reward-progress {
  height: 10px;
  margin: 0;
  background: #e7ece9;
  border-radius: var(--radius-full);
}

.reward-progress #targetProgress {
  background: linear-gradient(90deg, #1f7a5c, #36a879);
}

.reward-dashboard .empstats {
  margin-top: 12px;
}

.reward-dashboard .empstat {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 11px 13px;
}

.reward-dashboard .empstat b {
  font-size: 22px;
}

.reward-dashboard.target-achieved .reward-main {
  box-shadow: 0 0 0 1px #e5c15c, 0 7px 22px rgba(201, 155, 37, 0.14);
}

.reward-dashboard.target-achieved .reward-info::before {
  content: "🏆";
  font-size: 34px;
  margin-bottom: 3px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1180px) {
  main {
    grid-template-columns: minmax(0, 1fr) 270px;
    gap: 12px;
    padding: 14px;
  }

  table {
    min-width: 900px;
  }

  td.acts {
    min-width: 260px;
    max-width: 310px;
  }

  td.acts button.act {
    padding-inline: 7px;
    font-size: 10px;
  }
}

@media (max-width: 900px) {
  header {
    width: 100%;
    margin-right: 0;
    flex-wrap: wrap;
  }

  header nav {
    position: static;
    width: 100%;
    height: auto;
    padding: 10px;
    flex-direction: row;
    flex-wrap: wrap;
  }

  header nav::before,
  header nav::after {
    display: none;
  }

  .ops-nav-group {
    width: 100%;
  }

  main {
    display: block;
    margin-right: 0;
    padding: 12px;
  }

  #orderform {
    position: static;
    margin-bottom: 12px;
  }

  .scroll {
    max-height: none;
  }

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

  .bulkbar {
    flex-wrap: wrap;
  }

  dialog {
    width: calc(100vw - 16px);
  }

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

  .wallet-stats {
    grid-template-columns: 1fr 1fr;
  }

  .reward-main {
    grid-template-columns: 1fr;
  }

  .reward-counter {
    padding: 16px;
  }

  .reward-money span,
  .counter-number .num {
    font-size: 36px;
  }

  header .controls {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .orders.card {
    padding: 0;
    overflow: visible;
  }

  .orders.card > h2,
  .orders.card > .tabs,
  .orders.card > .filters,
  .orders.card > .bulkbar {
    margin-inline: 12px;
  }

  .scroll {
    overflow: visible;
    background: transparent;
  }

  .scroll table,
  .scroll thead,
  .scroll tbody,
  .scroll tr,
  .scroll td {
    display: block;
  }

  .scroll table {
    min-width: 0;
    width: 100%;
  }

  .scroll thead {
    display: none;
  }

  .scroll tbody {
    padding: 0 12px 12px;
  }

  .scroll tbody tr {
    position: relative;
    margin: 10px 0;
    padding: 12px;
    background: #fff;
    border: 1px solid #e2eaeb;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(18, 63, 73, 0.06);
  }

  .scroll tbody tr:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(18, 63, 73, 0.06);
  }

  .scroll tbody td {
    display: grid;
    grid-template-columns: minmax(82px, 32%) minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    min-height: 34px;
    padding: 8px 0;
    border-bottom: 1px solid #eef3f4;
    text-align: right;
  }

  .scroll tbody td::before {
    content: attr(data-label);
    color: #6f8186;
    font-size: 11px;
    font-weight: 800;
  }

  .scroll tbody td.mobile-order-head {
    display: block;
    min-height: 0;
    padding: 0 0 10px;
    border-bottom: 1px solid #eef3f4;
  }

  .scroll tbody td.mobile-order-head::before {
    display: none;
  }

  .mobile-order-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
  }

  .mobile-order-primary {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
  }

  .mobile-order-primary strong {
    flex-basis: 100%;
    color: #123f49;
    font-size: 14px;
  }

  .mobile-order-primary span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
  }

  .mobile-order-primary small {
    color: #6f8186;
    direction: ltr;
    unicode-bidi: isolate;
  }

  .mobile-order-summary > .chip {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    white-space: nowrap;
  }

  .mobile-order-toggle {
    grid-column: 1 / -1;
    justify-self: stretch;
    min-height: 34px;
    border: 1px solid #d9e6e7;
    border-radius: var(--radius-md);
    background: #f7fafb;
    color: #176a5a;
    font-size: 11px;
    font-weight: 800;
  }

  .mobile-shipment-status { grid-column: 1 / -1; }

  .scroll tbody tr:not(.is-expanded) > td:not(.mobile-order-head):not(.select-cell):not(.acts) {
    display: none;
  }

  .scroll tbody tr:not(.is-expanded) > td.select-cell {
    display: flex;
    position: absolute;
    top: 18px;
    inset-inline-end: 12px;
    padding: 0;
    border: 0;
  }

  .scroll tbody tr:not(.is-expanded) > td.acts {
    display: none;
  }

  .scroll tbody td.select-cell {
    display: flex;
    justify-content: flex-start;
    min-height: 0;
    padding-top: 0;
    border-bottom: 0;
  }

  .scroll tbody td.select-cell::before {
    display: none;
  }

  .scroll tbody td:last-child {
    border-bottom: 0;
  }

  .scroll tbody td.acts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
    max-width: none;
    padding-top: 10px;
  }

  .scroll tbody td.acts::before {
    flex-basis: 100%;
    content: "إجراءات";
  }

  .scroll tbody td.acts button,
  .scroll tbody td.acts select {
    min-height: 34px;
    max-width: 100%;
  }

  .scroll tbody td:not(.mobile-order-head):nth-child(2) {
    font-weight: 800;
    color: #123f49;
  }

  .scroll tbody tr::before {
    content: attr(data-status-label);
    position: absolute;
    top: 12px;
    inset-inline-start: 12px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e7f6f0;
    color: #17765b;
    font-size: 10px;
    font-weight: 800;
  }

}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ===== ADMIN SHELL LAYOUT FIXES =====
   Keep the right rail out of the document flow so page content never
   inherits a large blank top row or a full-width account/API column. */
body.admin-page {
  min-width: 0;
  overflow-x: hidden;
}

body.admin-page [hidden] {
  display: none !important;
}

body.admin-page > header {
  position: fixed;
  inset: 0 0 0 auto;
  width: var(--sidebar-width);
  height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  z-index: 1000;
}

body.admin-page > header h1 {
  flex: 0 0 auto;
  padding: 20px 16px;
}

body.admin-page > header nav {
  position: static;
  inset: auto;
  width: auto;
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
  margin: 0;
  padding: 68px 10px 12px;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  overflow-x: hidden;
  overflow-y: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
}

body.admin-page > header nav::before,
body.admin-page > header nav::after {
  content: none;
  display: none;
}

body.admin-page > header .controls {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

body.admin-page > header .controls #apikey {
  width: 100%;
  min-width: 0;
}

body.admin-page > main {
  width: auto;
  min-width: 0;
  margin-right: var(--sidebar-width);
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

body.admin-page > main > * {
  min-width: 0;
}

body.admin-page > main > .card,
body.admin-page > main > .orders.card {
  width: 100%;
  min-width: 0;
}

body.admin-page .filters {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto;
  align-items: end;
}

body.admin-page .filters .f,
body.admin-page .filters input,
body.admin-page .filters select {
  min-width: 0;
  width: 100%;
}

body.admin-page .filters .filter-check {
  min-width: max-content;
  margin: 0 0 8px;
}

body.admin-page .filters .hits {
  min-width: max-content;
  margin-inline-start: 0;
}

body.admin-page .scroll {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

body.admin-page .scroll table {
  min-width: 1100px;
}

body.admin-page .bulkbar,
body.admin-page .bulk-actions {
  flex-wrap: wrap;
}

@media (max-width: 1180px) and (min-width: 901px) {
  body.admin-page .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  }

  body.admin-page .filters .filter-check {
    min-width: 0;
  }
}

@media (max-width: 900px) {
  body.admin-page > header {
    position: static;
    inset: auto;
    width: 100%;
    height: auto;
    min-height: 0;
    display: flex;
  }

  body.admin-page > header nav {
    position: static;
    width: 100%;
    height: auto;
    flex: 0 0 auto;
    padding: 10px;
    flex-direction: row;
    flex-wrap: wrap;
    overflow: visible;
  }

  body.admin-page > header .controls {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    flex-wrap: wrap;
    align-items: center;
    border-top: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  body.admin-page > header .controls #currentuser {
    grid-column: 1 / -1;
    justify-self: start;
  }

  body.admin-page > header .controls label[for="apikey"] {
    grid-column: 1;
  }

  body.admin-page > header .controls #apikey {
    grid-column: 1;
    width: auto;
  }

  body.admin-page > header .controls #mode {
    grid-column: 1;
    justify-self: start;
  }

  body.admin-page > header .controls #logout {
    grid-column: 2;
    grid-row: 2 / span 3;
    align-self: center;
  }

  body.admin-page > main {
    width: 100%;
    margin-right: 0;
    padding: 14px;
  }

  body.admin-page .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.admin-page .filters .filter-check,
  body.admin-page .filters .clear,
  body.admin-page .filters .hits {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  body.admin-page > main {
    padding: 10px;
    gap: 12px;
  }

  body.admin-page .filters {
    grid-template-columns: minmax(0, 1fr);
  }

  body.admin-page .filters .filter-check,
  body.admin-page .filters .clear,
  body.admin-page .filters .hits {
    grid-column: auto;
  }

  body.admin-page .scroll {
    max-height: none;
    overflow: visible;
  }

  body.admin-page .scroll table,
  body.admin-page .scroll thead,
  body.admin-page .scroll tbody,
  body.admin-page .scroll tr,
  body.admin-page .scroll td {
    display: block;
  }

  body.admin-page .scroll table {
    width: 100%;
    min-width: 0;
  }

  body.admin-page .scroll thead {
    display: none;
  }

  body.admin-page .scroll tbody {
    padding: 0 12px 12px;
  }

  body.admin-page .scroll tbody tr {
    margin: 10px 0;
    padding: 12px;
    border: 1px solid var(--admin-line);
    border-radius: 8px;
    background: var(--admin-panel);
  }

  body.admin-page .scroll tbody td {
    display: grid;
    grid-template-columns: minmax(72px, 32%) minmax(0, 1fr);
    gap: 8px;
    min-width: 0;
    padding: 8px 0;
    border-bottom: 1px solid var(--admin-line);
    overflow-wrap: anywhere;
  }

  body.admin-page .scroll tbody td::before {
    content: attr(data-label);
    color: var(--admin-muted);
    font-size: 11px;
    font-weight: 700;
  }

  body.admin-page .scroll tbody td.mobile-order-head,
  body.admin-page .scroll tbody td.select-cell,
  body.admin-page .scroll tbody td.acts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }

  body.admin-page .scroll tbody td.mobile-order-head::before,
  body.admin-page .scroll tbody td.select-cell::before,
  body.admin-page .scroll tbody td.acts::before {
    content: none;
  }
}
