/* ─── ShipChip Admin · Design System ──────────────────────────────────────── */

:root {
  /* Brand */
  --navy:        #0B2447;
  --navy-deep:   #061730;
  --royal:       #1E40AF;
  --accent:      #EF6F5C;
  --accent-soft: #FDECE8;
  --sky:         #38BDF8;
  --sky-soft:    #E0F2FE;

  /* Surfaces */
  --bg:          #F4F7FB;
  --bg-deep:     #E2E8F2;
  --card:        #FFFFFF;
  --line:        #E2E8F0;
  --line-strong: #CBD5E1;

  /* Text */
  --text:        #0B2447;
  --text-muted:  #64748B;
  --text-subtle: #94A3B8;
  --text-on-navy:#F1F5F9;

  /* Status */
  --success:     #10B981;
  --warning:     #F59E0B;
  --danger:      #EF4444;
  --success-soft:#D1FAE5;
  --warning-soft:#FEF3C7;
  --danger-soft: #FEE2E2;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(11, 36, 71, 0.05);
  --shadow:    0 4px 14px rgba(11, 36, 71, 0.08);
  --shadow-lg: 0 12px 40px rgba(11, 36, 71, 0.14);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-feature-settings: 'kern';
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; font: inherit; }
input, select, textarea { font: inherit; }

/* ─── Login ───────────────────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
}
.login-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-card .brand-row {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-bottom: 4px;
}
.login-card .brand-row img { width: 56px; height: 56px; }
.login-card h1 {
  margin: 0; color: var(--navy); font-weight: 900; font-size: 32px;
  letter-spacing: -0.8px;
}
.login-card .tagline {
  margin: 0 0 28px; color: var(--text-muted); text-align: center; font-size: 14px;
}
.login-card input {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  text-align: right;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--royal);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.12);
}
.login-card button {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: 0; border-radius: var(--radius);
  font-weight: 700; font-size: 15px;
  transition: transform 0.1s, box-shadow 0.1s;
}
.login-card button:hover { box-shadow: 0 6px 20px rgba(239, 111, 92, 0.35); }
.login-card button:active { transform: scale(0.98); }
.login-card .err { color: var(--danger); margin-top: 8px; font-size: 14px; text-align: center; }

/* ─── Layout ──────────────────────────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  padding: 24px 16px;
  display: flex; flex-direction: column;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 24px; margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand img { width: 38px; height: 38px; }
.sidebar .brand .name {
  color: #fff; font-weight: 900; font-size: 22px;
  letter-spacing: -0.3px;
}
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav button {
  width: 100%;
  text-align: right;
  padding: 12px 16px;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  font-size: 14px;
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav button:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav button.active {
  background: rgba(56, 189, 248, 0.12);
  color: #fff;
  font-weight: 700;
  border-left: 3px solid var(--sky);
}
.sidebar .logout {
  margin-top: 16px;
  padding: 10px;
  background: rgba(239, 68, 68, 0.15);
  color: #FCA5A5;
  border: 0; border-radius: var(--radius);
  font-weight: 600;
  transition: background 0.15s;
}
.sidebar .logout:hover { background: rgba(239, 68, 68, 0.25); color: #fff; }

.main { flex: 1; padding: 32px; overflow: auto; }
.main h1 { margin-top: 0; font-weight: 800; color: var(--navy); letter-spacing: -0.4px; }

/* ─── KPI cards (kept compatible with old class names) ───────────────────── */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.card .value { font-size: 30px; font-weight: 800; margin-top: 4px; color: var(--navy); }
.card .value.success { color: var(--success); }
.card .value.warning { color: var(--warning); }
.card .value.primary { color: var(--royal); }

/* ─── Tables ──────────────────────────────────────────────────────────────── */

table {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
th, td { padding: 13px 16px; text-align: right; border-bottom: 1px solid var(--line); }
th { background: #F8FAFC; color: var(--text-muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}
.badge.OPEN { background: var(--warning); }
.badge.ACCEPTED, .badge.PICKED_UP { background: var(--royal); }
.badge.DELIVERED { background: var(--success); }
.badge.CANCELLED { background: var(--danger); }

.action-btn {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s;
}
.action-btn:hover { border-color: var(--royal); color: var(--royal); }
.action-btn.danger { background: var(--danger-soft); color: #B91C1C; border-color: #FECACA; }
.action-btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.action-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.action-btn.primary:hover { background: #DB5742; border-color: #DB5742; box-shadow: 0 4px 12px rgba(239, 111, 92, 0.3); }

#admin-map { height: 600px; border-radius: var(--radius-lg); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.empty { padding: 48px; text-align: center; color: var(--text-muted); }

/* ─── Modal ───────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 36, 71, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border-radius: var(--radius-xl);
  width: 100%; max-width: 800px; max-height: 90vh;
  overflow-y: auto; padding: 32px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h2 { margin: 0 0 4px; color: var(--navy); font-weight: 800; }
.modal .subtitle { color: var(--text-muted); margin: 0 0 24px; font-size: 14px; }
.modal-close {
  position: sticky; top: 0; float: left;
  background: var(--bg-deep); border: 0; border-radius: var(--radius-sm);
  padding: 6px 12px; font-size: 13px; font-weight: 600;
  margin-bottom: 16px; color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); }

.modal-section { margin-bottom: 24px; }
.modal-section h3 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; }

.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.action-grid button { padding: 10px; border-radius: var(--radius); border: 1px solid var(--line); background: #F8FAFC; font-size: 13px; font-weight: 600; text-align: center; transition: all 0.15s; }
.action-grid button:hover { transform: translateY(-1px); }
.action-grid button.danger  { background: var(--danger-soft);  border-color: #FECACA; color: #B91C1C; }
.action-grid button.primary { background: var(--sky-soft);     border-color: #BAE6FD; color: var(--royal); }
.action-grid button.success { background: var(--success-soft); border-color: #BBF7D0; color: #15803D; }
.action-grid button.warning { background: var(--warning-soft); border-color: #FDE68A; color: #92400E; }

.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.inline-form input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-align: right; }
.inline-form button { padding: 9px 16px; background: var(--accent); color: #fff; border: 0; border-radius: var(--radius-sm); white-space: nowrap; font-weight: 700; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag.green  { background: var(--success-soft); color: #065F46; }
.tag.red    { background: var(--danger-soft);  color: #991B1B; }
.tag.blue   { background: var(--sky-soft);     color: var(--royal); }
.tag.gray   { background: #F1F5F9;             color: #475569; }
.tag.yellow { background: var(--warning-soft); color: #92400E; }

.note-area { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); resize: vertical; min-height: 80px; text-align: right; font: inherit; }

.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th, .mini-table td { padding: 8px 12px; text-align: right; border-bottom: 1px solid #F1F5F9; }
.mini-table th { background: #F8FAFC; color: var(--text-muted); font-weight: 700; font-size: 11px; text-transform: uppercase; }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; }
.search-bar input { flex: 1; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius); text-align: right; }
.search-bar input:focus { outline: none; border-color: var(--royal); box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1); }
.search-bar label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }

tr.deleted td { opacity: 0.45; }
tr:hover td { background: #FAFAFA; }

/* ─── Professional dashboard ──────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: linear-gradient(135deg, #fff 0%, #fafbfd 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { box-shadow: var(--shadow-lg); border-color: var(--royal); }
.kpi.clickable:active { transform: translateY(0); }
.kpi::before {
  content: '';
  position: absolute;
  top: 0; right: 0; width: 4px; height: 100%;
  background: var(--accent, var(--accent));
}
.kpi.live::after {
  content: 'LIVE';
  position: absolute; top: 10px; left: 10px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 800;
  padding: 2px 6px; border-radius: 4px;
  letter-spacing: 0.05em;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.kpi-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; margin-bottom: 6px; }
.kpi-value { font-size: 32px; font-weight: 800; color: var(--navy); line-height: 1.1; }
.kpi-sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.kpi-delta { font-size: 12px; font-weight: 700; margin-top: 4px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1100px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.chart-panel h3 {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--navy);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chart-panel h3 .h-sub { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.chart-canvas-wrap { position: relative; height: 280px; }
.chart-canvas-wrap.tall { height: 340px; }

/* Live activity feed */
.feed { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.feed-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: #F8FAFC;
  border-radius: var(--radius);
  font-size: 13px;
  border-right: 3px solid var(--text-subtle);
  transition: background 0.15s;
}
.feed-item:hover { background: var(--bg-deep); }
.feed-item.created   { border-color: var(--warning); }
.feed-item.accepted  { border-color: var(--royal); }
.feed-item.delivered { border-color: var(--success); }
.feed-item.signup    { border-color: #8B5CF6; }
.feed-item.rating    { border-color: #F472B6; }
.feed-item .feed-text { flex: 1; color: var(--text); }
.feed-item .feed-time { color: var(--text-subtle); font-size: 11px; white-space: nowrap; }

/* Advanced edit form */
.edit-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.edit-form .full { grid-column: 1 / -1; }
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-group label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field-group input,
.field-group select,
.field-group textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: right;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--royal);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.12);
}
.field-group input[disabled] { background: #F8FAFC; color: var(--text-subtle); }
.field-group .helper { font-size: 11px; color: var(--text-subtle); margin-top: 2px; }
.field-row-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #F8FAFC;
  cursor: pointer;
  transition: background 0.15s;
}
.field-row-toggle:hover { background: var(--bg-deep); }
.field-row-toggle input { transform: scale(1.2); accent-color: var(--royal); }
.field-row-toggle span { flex: 1; font-size: 13px; color: var(--text); }

.save-bar {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid #F1F5F9;
}
.save-bar button {
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 0;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.15s;
}
.save-bar button.primary { background: var(--accent); color: #fff; }
.save-bar button.primary:hover { background: #DB5742; box-shadow: 0 4px 14px rgba(239, 111, 92, 0.35); }
.save-bar button.primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.save-bar button.secondary { background: #F1F5F9; color: var(--text-muted); }
.save-bar button.secondary:hover { background: var(--bg-deep); }

.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-left: 6px;
  animation: pulse 2s infinite;
}

/* ─── Business modal ─────────────────────────────────────────────────────── */

.biz-modal {
  max-width: 980px !important;
  width: 96vw;
  max-height: 92vh;
}

.biz-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.biz-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.biz-kpi {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.biz-kpi-l { font-size: 11px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.biz-kpi-v { font-size: 20px; font-weight: 800; color: var(--navy); }

.biz-quick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.biz-quick .action-btn { padding: 8px 14px; font-weight: 700; }

.biz-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.biz-tabs button {
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: #F1F5F9;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.biz-tabs button:hover { background: #E2E8F0; }
.biz-tabs button.active {
  background: var(--navy);
  color: #fff;
}

/* ─── Sidebar search button ──────────────────────────────────────────────── */

.sidebar-search {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.sidebar-search:hover { background: rgba(255, 255, 255, 0.16); }

/* ─── Global search modal ────────────────────────────────────────────────── */

.search-modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 0.2s ease-out;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.search-icon { font-size: 20px; }
.search-input-wrap input {
  flex: 1;
  border: 0;
  outline: none;
  font-size: 17px;
  background: transparent;
  color: var(--navy);
  font-family: inherit;
  text-align: right;
}
.search-input-wrap input::placeholder { color: var(--text-subtle); }
.search-close {
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
}

.search-hint {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}

.search-results {
  max-height: 60vh;
  overflow-y: auto;
}

.search-group { padding: 8px 0; }
.search-group:not(:last-child) { border-bottom: 1px solid var(--line); }
.search-group-title {
  padding: 8px 20px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 20px;
  background: transparent;
  border: 0;
  border-right: 3px solid transparent;
  text-align: right;
  cursor: pointer;
  transition: background 0.1s;
}
.search-result:hover {
  background: var(--bg);
  border-right-color: var(--accent);
}

/* ─── Settings rows ──────────────────────────────────────────────────────── */

.setting-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.setting-label { font-weight: 700; font-size: 15px; color: var(--navy); margin-bottom: 2px; }
.setting-hint  { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.setting-key   {
  display: inline-block; margin-top: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--text-subtle); background: rgba(11, 36, 71, 0.04);
  padding: 2px 8px; border-radius: 4px;
}
.setting-control { flex-shrink: 0; }
.setting-actions { display: flex; gap: 6px; flex-shrink: 0; }
