/* ============================================================
   GWM Australia – Daily Sales Reporting Tool
   Shared Stylesheet
   ============================================================ */

:root {
  --red:        #C41230;
  --red-dark:   #9B0E26;
  --black:      #111111;
  --white:      #FAFAFA;
  --gray-50:    #F7F7F7;
  --gray-100:   #EFEFEF;
  --gray-200:   #E2E2E2;
  --gray-400:   #9A9A9A;
  --gray-600:   #555555;
  --gray-800:   #2A2A2A;
  --late-bg:    #FFF3E0;
  --late-text:  #C84B00;
  --success-bg: #E8F5E9;
  --success:    #2E7D32;
  --error-bg:   #FFEBEE;
  --error:      #C62828;
  --font:       'Helvetica Neue', Helvetica, Arial, sans-serif;
  --radius:     4px;
  --shadow:     0 1px 4px rgba(0,0,0,0.10);
  --shadow-lg:  0 4px 16px rgba(0,0,0,0.12);
}

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100dvh;
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  background: var(--black);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06), 0 3px 12px rgba(0,0,0,0.4);
  border-bottom: 2px solid var(--red);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.gwm-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.gwm-badge-img {
  height: 36px;
  width: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.gwm-wordmark-img {
  height: 32px;
  object-fit: contain;
  opacity: 1;
}

.header-title {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  border-left: 1px solid #2e2e2e;
  padding-left: 16px;
  letter-spacing: 0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-clock {
  font-size: 12px;
  color: var(--gray-400);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.late-badge {
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 2px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: none;
}
.late-badge.visible { display: inline-block; }

/* ── Main layout ─────────────────────────────────────────── */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.main-content.wide {
  max-width: 1280px;
}

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-400);
  margin-bottom: 14px;
}

/* ── Form elements ───────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-row.single { grid-template-columns: 1fr; }

@media (max-width: 540px) {
  .form-row, .form-row.three { grid-template-columns: 1fr; }
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-600);
}

.form-label .required {
  color: var(--red);
  margin-left: 2px;
}

.form-input,
.form-select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-800);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M0 0l6 7 6-7z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(196,18,48,0.12);
}

.form-input.error,
.form-select.error {
  border-color: var(--red);
}

.form-input[readonly] {
  background: var(--gray-50);
  color: var(--gray-600);
  cursor: default;
}

/* ── Direction control ───────────────────────────────────── */
.direction-group {
  display: flex;
  gap: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  height: 40px;
}

.direction-btn {
  flex: 1;
  border: none;
  background: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  border-right: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.direction-btn:last-child { border-right: none; }

.direction-btn[data-val="Up"].active    { background: #E8F5E9; color: #2E7D32; }
.direction-btn[data-val="Flat"].active  { background: #F3F3F3; color: #444; }
.direction-btn[data-val="Down"].active  { background: #FFEBEE; color: #C62828; }

/* ── Live totals bar ─────────────────────────────────────── */
.totals-bar {
  background: var(--black);
  border-radius: var(--radius);
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  overflow: hidden;
}

.total-item {
  flex: 1;
  padding: 12px 16px;
  text-align: center;
  border-right: 1px solid #2a2a2a;
}
.total-item:last-child { border-right: none; }

.total-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  margin-bottom: 4px;
}

.total-value {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.total-item.highlight .total-value { color: var(--red); }

@media (max-width: 540px) {
  .totals-bar { flex-wrap: wrap; }
  .total-item { min-width: 50%; border-bottom: 1px solid #2a2a2a; }
}

/* ── Model grid ──────────────────────────────────────────── */
.grid-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -20px;
  padding: 0 20px;
}

.model-grid {
  width: 100%;
  border-collapse: collapse;
  min-width: 580px;
  font-size: 13px;
}

.model-grid thead th {
  position: sticky;
  top: 60px;
  background: var(--gray-50);
  z-index: 10;
  padding: 9px 8px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

.model-grid thead th:first-child {
  text-align: left;
  padding-left: 0;
  min-width: 160px;
}

.model-grid tbody tr:nth-child(even) td { background: var(--gray-50); }
.model-grid tbody tr:hover td { background: #FEF2F4; }

.model-grid td {
  padding: 4px 4px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.model-grid td.model-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-800);
  padding-left: 0;
  padding-right: 10px;
  white-space: nowrap;
}

.grid-input {
  width: 100%;
  min-width: 60px;
  height: 36px;
  text-align: center;
  border: 1px solid var(--gray-200);
  border-radius: 3px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
  background: #fff;
  padding: 0 4px;
  transition: border-color 0.12s, background 0.12s;
  -moz-appearance: textfield;
}

.grid-input::-webkit-outer-spin-button,
.grid-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.grid-input:focus {
  outline: none;
  border-color: var(--red);
  background: #fff8f9;
  box-shadow: 0 0 0 2px rgba(196,18,48,0.10);
}

.grid-input.nonzero {
  font-weight: 700;
  color: var(--black);
}

/* Row totals */
.row-total {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: var(--gray-600);
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--red);
  color: #fff;
  width: 100%;
  height: 52px;
  font-size: 16px;
}
.btn-primary:hover { background: var(--red-dark); }
.btn-primary:disabled { background: var(--gray-400); cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-800);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-outline {
  background: transparent;
  color: var(--red);
  border: 1.5px solid var(--red);
}
.btn-outline:hover { background: #FEF2F4; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
}

/* ── Toast / feedback ────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--black);
  color: #fff;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 48px);
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error   { background: #C62828; }

/* ── Alert banner ────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert.success { background: var(--success-bg); color: var(--success); border: 1px solid #A5D6A7; }
.alert.error   { background: var(--error-bg);   color: var(--error);   border: 1px solid #EF9A9A; }
.alert.warning { background: var(--late-bg);     color: var(--late-text); border: 1px solid #FFCC80; }
.alert.hidden  { display: none; }

/* ── Dashboard KPI grid ──────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border-top: 3px solid var(--gray-200);
}

.kpi-card.accent { border-top-color: var(--red); }
.kpi-card.success { border-top-color: var(--success); }
.kpi-card.warning { border-top-color: var(--late-text); }

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--gray-400);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--black);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Dashboard tables ────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  background: var(--gray-50);
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.data-table thead th:hover { color: var(--red); }

.data-table thead th.num { text-align: right; }

.data-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
}

.data-table tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.data-table tbody tr:hover td { background: var(--gray-50); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-green  { background: #E8F5E9; color: #2E7D32; }
.badge-red    { background: #FFEBEE; color: #C62828; }
.badge-gray   { background: #F3F3F3; color: #555; }
.badge-orange { background: #FFF3E0; color: #C84B00; }

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
}

.filter-input,
.filter-select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  color: var(--gray-800);
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
}

.filter-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  min-width: 140px;
}

.filter-input:focus, .filter-select:focus {
  outline: none;
  border-color: var(--red);
}

/* ── Charts ──────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .charts-row { grid-template-columns: 1fr; }
}

.chart-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.chart-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-400);
  margin-bottom: 16px;
}

/* ── Nav tabs (dashboard) ────────────────────────────────── */
.page-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--gray-200);
}

.page-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.12s;
}

.page-tab:hover { color: var(--gray-800); }
.page-tab.active { color: var(--red); border-bottom-color: var(--red); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Config overlay ──────────────────────────────────────── */
.config-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.config-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.config-box h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.config-box p {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 18px;
  line-height: 1.5;
}

/* ── Section header ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--gray-400);
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.spinner.visible { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-red { color: var(--red); }
.text-gray { color: var(--gray-400); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
