/* Arbitrade Store — minimal dark theme */

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

:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --border:   #2a2d3a;
  --text:     #e2e4ea;
  --muted:    #7a7d8f;
  --accent:   #4f8ef7;
  --green:    #3ecf8e;
  --yellow:   #f5a623;
  --red:      #e05252;
  --radius:   6px;
  --font:     system-ui, -apple-system, "Segoe UI", sans-serif;
}

body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 52px;
  gap: 32px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .brand { font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: .02em; white-space: nowrap; }
.site-header nav { display: flex; gap: 20px; }
.site-header nav a { color: var(--muted); font-size: 13px; min-height: 44px; display: flex; align-items: center; }
.site-header nav a:hover { color: var(--text); text-decoration: none; }
.site-header .logout { margin-left: auto; }
.site-header .logout form button {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; min-height: 44px;
}
.site-header .logout form button:hover { color: var(--text); }

.hamburger {
  display: none;
  background: none; border: none; color: var(--text); font-size: 22px; cursor: pointer;
  min-height: 44px; min-width: 44px; padding: 0 4px;
}

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; }

/* ── Toggle switch ── */
.toggle-switch { position:relative; display:inline-block; width:44px; height:24px; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-slider {
  position:absolute; cursor:pointer; inset:0;
  background:var(--red); border-radius:24px; transition:.2s;
}
.toggle-slider::before {
  content:''; position:absolute;
  width:18px; height:18px; left:3px; bottom:3px;
  background:#fff; border-radius:50%; transition:.2s;
}
.toggle-switch input:checked + .toggle-slider { background:var(--green); }
.toggle-switch input:checked + .toggle-slider::before { transform:translateX(20px); }

/* ── Cards / panels ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.panel-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Dashboard grid ── */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.stat-row { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 8px; }
.stat { text-align: center; }
.stat .num { font-size: 28px; font-weight: 700; }
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.clickable-num { cursor: pointer; color: var(--accent); text-decoration: underline; text-decoration-style: dotted; }
.clickable-num:hover { opacity: .8; }

/* ── Tables ── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; padding: 8px 12px; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.02); }

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--text); }
.sort-arrow { font-size: 10px; }

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: rgba(79,142,247,.06) !important; }

.sku-link { color: var(--text); }
.sku-link:hover { color: var(--accent); }

.tracking-dash { cursor: pointer; color: var(--accent); font-style: italic; }
.tracking-dash:hover { text-decoration: underline; }

/* ── Status badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-green  { background: rgba(62,207,142,.15); color: var(--green); }
.badge-yellow { background: rgba(245,166,35,.15);  color: var(--yellow); }
.badge-red    { background: rgba(224,82,82,.15);   color: var(--red); }
.badge-blue   { background: rgba(79,142,247,.15);  color: var(--accent); }
.badge-muted  { background: rgba(122,125,143,.15); color: var(--muted); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input[type=password], input[type=text], input[type=number] {
  width: 100%; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
}
input:focus { outline: none; border-color: var(--accent); }
select { padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); font-size: 13px; }
select:focus { outline: none; border-color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-block; padding: 10px 18px;
  border-radius: var(--radius); font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: opacity .15s; min-height: 44px;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 36px; }
.btn-action { background: var(--surface); border: 1px solid var(--border); color: var(--text); }

/* ── Login page ── */
.login-wrap { max-width: 360px; margin: 80px auto; }
.login-wrap .brand { font-size: 22px; font-weight: 700; margin-bottom: 24px; text-align: center; }
.error-msg { color: var(--red); font-size: 13px; margin-bottom: 12px; }

/* ── Homepage ── */
.home-hero { max-width: 680px; margin: 80px auto; padding: 0 24px; }
.home-hero h1 { font-size: 32px; font-weight: 700; margin-bottom: 16px; }
.home-hero p { color: var(--muted); line-height: 1.7; margin-bottom: 12px; }
.home-hero .contact { margin-top: 32px; color: var(--muted); font-size: 13px; }

/* ── Action result box ── */
.action-result {
  display: none; margin-top: 12px; padding: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  font-family: monospace; font-size: 12px; white-space: pre-wrap; color: var(--green);
}
.action-result.error { color: var(--red); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 900;
  padding: 16px;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 600px;
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; font-size: 15px; }
.modal-close {
  background: none; border: none; color: var(--muted); font-size: 18px;
  cursor: pointer; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

.detail-table { width: 100%; font-size: 13px; }
.detail-table td { padding: 5px 0; vertical-align: top; }
.detail-table td:first-child { color: var(--muted); padding-right: 16px; white-space: nowrap; width: 40%; }

/* ── Misc ── */
.text-muted { color: var(--muted); }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.full-width { grid-column: 1 / -1; }

/* ── Mobile responsive ── */
@media (max-width: 768px) {
  /* Hamburger menu */
  .hamburger { display: flex; align-items: center; justify-content: center; }

  .site-header nav {
    display: none;
    position: absolute; top: 52px; left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    flex-direction: column; gap: 0; z-index: 800; padding: 8px 0;
  }
  .site-header nav.open { display: flex; }
  .site-header nav a {
    padding: 12px 24px; min-height: 48px; border-bottom: 1px solid var(--border); width: 100%;
  }
  .site-header nav a:last-child { border-bottom: none; }
  .site-header .logout { display: none; }

  /* Stack grid panels vertically */
  .dash-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: 1; }

  /* Container padding */
  .container { padding: 16px; }
  .page-title { font-size: 18px; }

  /* Table card-style on mobile */
  .tbl-wrap table thead { display: none; }
  .tbl-wrap table, .tbl-wrap tbody, .tbl-wrap tr, .tbl-wrap td {
    display: block; width: 100%;
  }
  .tbl-wrap tr {
    border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 8px; padding: 8px 12px;
  }
  .tbl-wrap td {
    border: none; padding: 2px 0;
    display: flex; gap: 8px; align-items: flex-start; font-size: 13px;
  }
  .tbl-wrap td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 11px; font-weight: 600;
    text-transform: uppercase; min-width: 90px; flex-shrink: 0;
  }

  /* Keep pipeline/alerts tables scrollable instead of card layout (too many columns) */
  .tbl-keep-table thead { display: table-header-group; }
  .tbl-keep-table table, .tbl-keep-table tbody, .tbl-keep-table tr, .tbl-keep-table td { display: revert; }
  .tbl-keep-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Buttons minimum touch target */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; padding: 8px 14px; }

  /* Modal full-width on mobile */
  .modal-box { max-width: 100%; max-height: 95vh; margin: 0; border-radius: 0; }
  .modal-overlay { padding: 0; align-items: flex-end; }

  /* Forms */
  input[type=text], input[type=password], input[type=number], select {
    font-size: 16px; /* prevent iOS zoom on focus */
  }

  /* Login page */
  .login-wrap { margin: 40px auto; padding: 0 16px; }

  /* Home page */
  .home-hero { margin: 40px auto; }
  .home-hero h1 { font-size: 24px; }
}
