/* ============================================================
   C TWO Order Control System — global stylesheet
   ============================================================ */
:root {
  --navy:     #1a2f5e;
  --navy-lt:  #24407e;
  --blue:     #0066cc;
  --blue-lt:  #e8f0fa;
  --ink:      #222222;
  --muted:    #666666;
  --line:     #dde3ec;
  --bg:       #f5f6f8;
  --white:    #ffffff;
  --hover:    #eef2f9;
  --pending:  #c47f17;
  --approved: #2a7d45;
  --rejected: #c0392b;
  --radius:     8px;
  --radius-sm:  5px;
  --shadow-sm:  0 1px 2px rgba(20,30,60,.05);
  --shadow-md:  0 4px 14px rgba(20,30,60,.08);
  --shadow-lg:  0 12px 32px rgba(20,30,60,.16);
  --ring:       0 0 0 3px rgba(0,102,204,.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scrollbar-color: #c3ccdb var(--bg); }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3ccdb; border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #a9b6cb; }

/* ── Header ──────────────────────────────────────────────── */
header {
  background: linear-gradient(180deg, var(--navy-lt), var(--navy) 60%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 54px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(10,16,32,.3);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-c   { color: #ffffff; font-size: 22px; font-weight: 800; letter-spacing: -1px; }
.brand-two { color: #5ba3f5; font-size: 22px; font-weight: 800; letter-spacing: -1px; }
.brand-sep { width: 1px; height: 20px; background: rgba(255,255,255,.25); margin: 0 14px; }
.brand-sub { color: rgba(255,255,255,.65); font-size: 11px; font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase; }

nav.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  padding-left: 20px;
}
nav.main-nav a {
  position: relative;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
nav.main-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
nav.main-nav a.active {
  background: rgba(255,255,255,.16);
  color: #fff;
}
nav.main-nav a.active::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -3px;
  height: 2px;
  border-radius: 2px;
  background: #5ba3f5;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.header-user { color: rgba(255,255,255,.65); font-size: 13px; }
.btn-logout {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, border-color .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.35); }

/* ── Layout ──────────────────────────────────────────────── */
main { max-width: 1400px; margin: 0 auto; padding: 24px 28px 60px; }

h1 {
  color: var(--navy);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .3px;
  margin-bottom: 16px;
}

/* ── Filters bar ─────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}
.filters input[type="text"],
.filters select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--white);
  color: var(--ink);
  height: 34px;
  transition: border-color .15s, box-shadow .15s;
}
.filters input[type="text"]:focus,
.filters select:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
.filters input[type="text"] { min-width: 220px; flex: 1; }
.filters select              { min-width: 130px; }
.count-badge { color: var(--muted); font-size: 13px; margin-left: auto; white-space: nowrap; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: transform .12s ease, box-shadow .12s ease, background .15s, border-color .15s, opacity .15s;
  text-decoration: none;
}
.btn:hover  { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-primary  { background: var(--blue);  color: #fff; }
.btn-primary:hover  { background: #0072e0; }
.btn-success  { background: var(--approved); color: #fff; }
.btn-success:hover  { background: #308f4e; }
.btn-danger   { background: var(--rejected); color: #fff; }
.btn-danger:hover   { background: #cc4536; }
.btn-warning  { background: var(--pending);  color: #fff; }
.btn-warning:hover  { background: #d68c1f; }
.btn-ghost    { background: var(--white); border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: #c3ccdb; background: var(--hover); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--white); box-shadow: var(--shadow-sm); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--navy);
  color: #fff;
  font-weight: 500;
  font-size: 12px;
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
th.sortable { cursor: pointer; user-select: none; transition: background .12s; }
th.sortable:hover { background: #243e78; }
th.sort-active { background: #1e3570; }
.sort-ind { font-size: 9px; margin-left: 3px; opacity: .8; }
th.num, td.num { text-align: right; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; transition: background .1s; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--hover); }
tbody tr.clickable { cursor: pointer; }

.sku  { font-weight: 600; color: var(--navy); }
.name { white-space: normal; max-width: 220px; }
.note { color: var(--muted); max-width: 180px; white-space: normal; font-size: 12px; }
.active-yes { color: var(--approved); font-weight: 600; }
.active-no  { color: var(--muted); }

/* ── Status badges ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: currentColor;
  flex-shrink: 0;
}
.badge-pending  { background: #fef3dc; color: var(--pending); }
.badge-approved { background: #d4edda; color: var(--approved); }
.badge-rejected { background: #fde8e8; color: var(--rejected); }

/* ── Detail view ─────────────────────────────────────────── */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.detail-header h1 { margin-bottom: 4px; }
.meta { color: var(--muted); font-size: 13px; line-height: 1.7; }
.meta strong { color: var(--ink); }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 14px;
}

/* Shipping inputs */
.ship-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.ship-row .ship-grid { flex: 1; min-width: 300px; }
.ship-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.ship-notes { flex: 0 0 280px; min-width: 180px; }
.ship-notes label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 5px;
}
.ship-notes textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 98px;
  background: var(--white);
  color: var(--ink);
}
.ship-notes textarea { transition: border-color .15s, box-shadow .15s; }
.ship-notes textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
.ship-notes textarea[readonly] { background: var(--bg); }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 5px;
}
.field input, .field select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
.field input[readonly] { background: var(--bg); color: var(--muted); }

/* Price matrix */
.price-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.price-table th {
  background: var(--navy);
  color: #fff;
  padding: 8px 10px;
  text-align: right;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  top: 0;
}
.price-table th:first-child,
.price-table th:nth-child(2) { text-align: left; }
.price-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.price-table td:first-child { font-weight: 500; padding-left: 8px; min-width: 130px; }
.price-table td:nth-child(2) { min-width: 180px; }

.price-table input[type="number"],
.price-table input[type="text"] {
  width: 72px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  text-align: right;
  transition: border-color .15s, box-shadow .15s;
}
.price-table input:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
.price-table select {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  transition: border-color .15s;
}
.price-table select:focus { outline: none; border-color: var(--blue); }

/* Price matrix footer rows */
.row-subtotal td { border-top: 2px solid var(--line); font-weight: 600; background: var(--bg); }
.row-freight td  { background: var(--bg); color: var(--muted); font-style: italic; }
.row-total td    { border-top: 2px solid var(--navy); font-weight: 700; color: var(--navy); background: var(--blue-lt); font-size: 13px; }
.row-delete      { cursor: pointer; color: var(--muted); font-size: 16px; padding: 0 6px; }
.row-delete:hover { color: var(--rejected); }

.price-table td.num-display { text-align: right; font-variant-numeric: tabular-nums; }

/* Action bar below table */
.action-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ── Admin sections ──────────────────────────────────────── */
.admin-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--line); margin-bottom: 24px; }
.admin-tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.admin-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.admin-tab:hover  { color: var(--navy); border-bottom-color: var(--line); }

.admin-section { display: none; }
.admin-section.active { display: block; }

.inline-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--blue-lt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.inline-form .field { flex: 1; min-width: 150px; }

/* Template detail panel */
.tmpl-detail {
  background: var(--white);
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 16px;
}

/* ── Buyer action buttons ────────────────────────────────── */
.approve-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 20px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.approve-bar .current-status { font-size: 13px; color: var(--muted); flex: 1; }

/* ── Empty / loading states ─────────────────────────────── */
.empty { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 14px; }
.loading { text-align: center; color: var(--muted); padding: 30px; }

/* ── Back link ───────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 18px;
}
.back-link:hover { text-decoration: underline; }

/* ── Login ───────────────────────────────────────────────── */
body:has(.login-wrap) {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(91,163,245,.14), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(26,47,94,.08), transparent 60%),
    var(--bg);
}
.login-wrap {
  max-width: 380px;
  margin: 80px auto;
  padding: 36px 32px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand-c   { font-size: 32px; font-weight: 800; color: var(--navy); }
.login-logo .brand-two { font-size: 32px; font-weight: 800; color: var(--blue); }
.login-logo p { color: var(--muted); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; margin-top: 4px; }
.login-wrap .field { margin-bottom: 16px; }
.login-wrap label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; }
.login-wrap input  { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.login-wrap input:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
.login-wrap .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 14px; margin-top: 8px; }
.error-msg { color: var(--rejected); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ── Generic modal (add/edit dialogs across admin pages) ──── */
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn   { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.profit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,22,40,.55);
  z-index: 200;
  overflow-y: auto;
  padding: 30px 16px 60px;
  animation: overlayIn .15s ease;
}
.profit-card {
  background: var(--white);
  max-width: 1100px;
  margin: 0 auto;
  border-radius: 12px;
  padding: 28px 32px;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s cubic-bezier(.2,.8,.2,1);
}
.profit-close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 99px;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  transition: background .15s, color .15s;
}
.profit-close:hover { color: var(--ink); background: var(--hover); }
.profit-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 2px;
  margin-bottom: 20px;
}

/* ── Profit calculation card (buyer) ─────────────────────── */
.profit-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  gap: 12px;
}
.row-profit-cost td    { font-weight: 600; background: var(--bg); border-top: 2px solid var(--line); }
.row-profit-trade td   { border-top: 2px solid var(--navy); font-weight: 700; color: var(--navy); background: var(--blue-lt); font-size: 13px; }
.row-profit-pct td     { color: var(--approved); font-weight: 600; background: var(--bg); font-size: 12px; }
.row-profit-pcs td     { background: var(--bg); font-size: 12px; color: var(--muted); }
.row-profit-stagger td { background: var(--bg); font-size: 12px; color: var(--muted); }

/* ── Export bar ──────────────────────────────────────────── */
.export-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.export-bar .export-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-right: 2px;
}
.export-bar select {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--white);
  color: var(--ink);
  height: 28px;
}

/* ── Currency selector (header) ─────────────────────────── */
.currency-sel {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.currency-sel option { background: var(--navy); color: #fff; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 700px) {
  main { padding: 16px 12px 40px; }
  header { padding: 0 14px; }
  .brand-sub, .brand-sep { display: none; }
  nav.main-nav { padding-left: 10px; gap: 2px; }
  nav.main-nav a { padding: 6px 10px; font-size: 12px; }
}
