/* ShopTrack theme — matches R&R Fabrication OS (light CRM theme)
   Palette: slate + orange (#f97316). System sans-serif. */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --border: #e2e8f0;
  --sidebar: #0f172a;
  --sidebar-muted: #94a3b8;
  --sidebar-hover: #1e293b;
  --sidebar-text: #cbd5e1;
  --accent: #f97316;
  --accent-dim: #ea580c;
  --text: #0f172a;
  --text-muted: #64748b;
  --success: #16a34a;
  --danger: #ef4444;
  --warning: #d97706;
  --radius: 12px;
  --sidebar-width: 240px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Aliases so older page-level styles pick up the new palette */
  --orange: #f97316;
  --primary: #f97316;
  --navy: #f8fafc;
  --muted: #64748b;
  --green: #16a34a;
  --blue: #2563eb;
  --red: #ef4444;
  --purple: #7c3aed;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* SIDEBAR */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width); height: 100vh;
  background: var(--sidebar); color: #f1f5f9;
  display: flex; flex-direction: column;
  padding: 0.9rem 0.7rem; overflow-y: auto; z-index: 200;
  transition: transform 0.2s ease;
}
.side-brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.5rem 1rem; text-decoration: none; color: #fff; }
.side-brand .logo { width: 38px; height: 38px; border-radius: 9px; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; font-size: 0.95rem; flex-shrink: 0; }
.side-brand .bt { font-weight: 800; font-size: 1.02rem; line-height: 1.1; }
.side-brand .bt small { display: block; font-weight: 500; color: var(--sidebar-muted); font-size: 0.72rem; }
.side-nav { display: flex; flex-direction: column; }
.nav-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.65rem; border-radius: 9px; color: var(--sidebar-text); font-weight: 500; font-size: 0.92rem; text-decoration: none; margin-bottom: 0.15rem; transition: background 0.15s, color 0.15s; }
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-hover); color: #fff; }
.nav-item.active svg { stroke: var(--accent); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.5rem 0.3rem; border-top: 1px solid var(--sidebar-hover); }
.side-foot .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.side-foot .un { font-size: 0.85rem; font-weight: 600; color: #f1f5f9; }
.side-foot .rl { font-size: 0.72rem; color: var(--sidebar-muted); text-transform: capitalize; }
.side-foot .out { margin-left: auto; color: var(--sidebar-muted); text-decoration: none; }
.side-foot .out:hover { color: var(--danger); }
.side-foot .out svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.side-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 150; }
.side-backdrop.open { display: block; }

/* MAIN AREA */
.app-main { margin-left: var(--sidebar-width); min-height: 100vh; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0.65rem 1.5rem; display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 90; }
.topbar .hamburger { display: none; background: none; border: none; cursor: pointer; width: 40px; height: 40px; border-radius: 9px; align-items: center; justify-content: center; flex-direction: column; gap: 5px; }
.topbar .hamburger span { display: block; width: 22px; height: 2px; background: var(--text-muted); border-radius: 2px; }
.topbar .tb-title { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.topbar .tb-spacer { flex: 1; }

/* LAYOUT */
.container { max-width: 1120px; margin: 0 auto; padding: 1.6rem 1.8rem; }
.page-header { margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.page-title { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.01em; color: var(--text); }
.page-title span { color: var(--accent); }

/* CARDS */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; box-shadow: 0 1px 2px rgba(15,23,42,0.04); }
.card-header { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 1rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--border); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center; box-shadow: 0 1px 2px rgba(15,23,42,0.04); }
.stat-value { font-size: 2.3rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.35rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.35rem; }
.form-control { width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 9px; color: var(--text); padding: 0.65rem 0.85rem; font-size: 1rem; font-family: var(--font); transition: border-color 0.15s, box-shadow 0.15s; -webkit-appearance: none; }
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249,115,22,0.15); }
.form-control option { background: #fff; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }
.time-pair { display: flex; gap: 0.5rem; align-items: center; }
.time-pair .form-control { text-align: center; }
.time-sep { color: var(--text-muted); font-weight: 700; font-size: 1.2rem; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.6rem 1.15rem; border-radius: 9px; border: none; font-family: var(--font); font-size: 0.95rem; font-weight: 700; cursor: pointer; text-decoration: none; transition: all 0.15s; white-space: nowrap; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 1.1rem; width: 100%; }

/* TABLES */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th { background: var(--surface2); color: var(--text-muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; padding: 0.65rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); }
tbody td { padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--border); color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(249,115,22,0.05); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.font-mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }

/* ALERTS */
.alert { padding: 0.85rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; font-weight: 500; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* EMPLOYEE ENTRY BLOCK */
.employee-entry { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.75rem; transition: border-color 0.15s; }
.employee-entry.has-data { border-color: var(--accent); }
.employee-name-label { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 0.75rem; }
.job-split-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.job-split-block { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem; margin-bottom: 0.5rem; }
.pieces-input { font-size: 0.9rem; color: var(--text-muted); border-style: dashed; }
.pieces-input:focus { border-style: solid; color: var(--text); }
.add-split-btn { background: none; border: 1px dashed var(--border); color: var(--text-muted); cursor: pointer; padding: 0.4rem 0.75rem; border-radius: 9px; font-size: 0.8rem; font-family: var(--font); transition: all 0.15s; margin-top: 0.25rem; }
.add-split-btn:hover { border-color: var(--accent); color: var(--accent); }
.remove-split { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; padding: 0.2rem 0.4rem; border-radius: 4px; transition: background 0.15s; }
.remove-split:hover { background: #fee2e2; }

/* LOGIN PAGE */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 1rem; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius); padding: 2rem 1.75rem; width: 100%; max-width: 380px; box-shadow: 0 4px 20px rgba(15,23,42,0.08); }
.login-logo { font-size: 1.8rem; font-weight: 800; color: var(--text); text-align: center; margin-bottom: 0.25rem; }
.login-logo span { color: var(--accent); }
.login-sub { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.75rem; }

/* SETTINGS MENU (index) */
.settings-menu { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.settings-menu a { display: flex; align-items: center; gap: 0.9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; text-decoration: none; color: var(--text); box-shadow: 0 1px 2px rgba(15,23,42,0.04); transition: border-color 0.15s; }
.settings-menu a:hover { border-color: var(--accent); }
.settings-menu .si { width: 42px; height: 42px; border-radius: 10px; background: var(--surface2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.settings-menu .si svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 2; }
.settings-menu .st { font-weight: 700; font-size: 1.02rem; }
.settings-menu .sd { color: var(--text-muted); font-size: 0.83rem; }
.settings-menu .arw { margin-left: auto; color: var(--text-muted); font-size: 1.3rem; }

/* SETTINGS SUB-NAV */
.settings-tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.4rem; flex-wrap: wrap; }
.settings-tabs a { color: var(--text-muted); text-decoration: none; padding: 0.6rem 1rem; font-weight: 700; font-size: 0.92rem; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.15s; }
.settings-tabs a:hover { color: var(--text); }
.settings-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-tabs a.back { color: var(--text-muted); }

/* DIVIDER */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* PILL / STATUS */
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.pill-active { background: #dcfce7; color: #15803d; }
.pill-completed { background: #dbeafe; color: #1d4ed8; }
.pill-hold { background: #fef3c7; color: #b45309; }
.pill-scheduled { background: #ffedd5; color: var(--accent-dim); }
.pill-shipped { background: #dcfce7; color: #15803d; }

/* TABS (in-page) */
.tabs { display: flex; gap: 0.25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.tab { padding: 0.6rem 1rem; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s; font-family: var(--font); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* DATE PICKER */
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; }

/* SECTION HEADERS */
.section-header { font-size: 1.05rem; font-weight: 700; color: var(--text); padding: 0.6rem 0 0.4rem; margin-top: 0.5rem; border-bottom: 1px solid var(--border); margin-bottom: 0.75rem; }

/* YARD ENTRY */
.yard-entry { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.75rem; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.4); }
  .app-main { margin-left: 0; }
  .topbar .hamburger { display: flex; }
  .container { padding: 1rem 0.9rem; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .page-header .btn { width: 100%; justify-content: center; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .form-control { padding: 0.85rem 1rem; font-size: 1rem; }
  .form-label { font-size: 0.82rem; margin-bottom: 0.4rem; }
  .btn-lg { font-size: 1.1rem; padding: 1rem 1.5rem; }
  .employee-entry { padding: 0.875rem; }
  .employee-name-label { font-size: 1.15rem; }
  .job-split-row { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
  .job-split-block { padding: 0.75rem; }
  .time-pair .form-control { padding: 0.85rem 0.5rem; font-size: 1.1rem; text-align: center; }
  .time-sep { font-size: 1.4rem; }
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 0.85rem; min-width: 500px; }
  thead th, tbody td { padding: 0.6rem 0.65rem; }
  .card { padding: 1rem; }
  .card-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .stat-card { padding: 1rem; }
  .stat-value { font-size: 2rem; }
  .two-col { grid-template-columns: 1fr !important; }
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 0.75rem; }
  .kpi-value { font-size: 1.6rem; }
  .yard-entry { padding: 0.875rem; }
  .alert { font-size: 0.95rem; padding: 0.875rem 1rem; }
  .filter-bar { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .filter-bar input[type=date] { width: 100%; padding: 0.65rem 0.75rem; font-size: 1rem; }
  .filter-shortcut { padding: 0.55rem 0.75rem; font-size: 0.82rem; }
  .btn-filter { padding: 0.65rem; font-size: 0.9rem; }
  .filter-range-label { margin-left: 0; }
  .filter-tabs { flex-wrap: wrap; }
  .ftab { padding: 4px 10px; }
  .db-card-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .report-grid { grid-template-columns: 1fr !important; }
  .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
@media (min-width: 769px) and (max-width: 1000px) {
  .container { padding: 1.4rem 1.2rem; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@supports (padding: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .sidebar { padding-left: max(0.7rem, env(safe-area-inset-left)); }
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
.table-wrapper { -webkit-overflow-scrolling: touch; }
