/* ============================================================
   ATMAN ERP — Design Tokens
   Palette echoes ATMAN's own product world: deep dark surfaces
   with a warm gold/amber "light source" accent.
   ============================================================ */

:root {
  --bg-deep: #0b0d10;
  --surface: #15181d;
  --surface-raised: #1c1f26;
  --border-hairline: #262a32;

  --gold: #c9a227;
  --amber-glow: #ffc85c;

  --text-primary: #edeae2;
  --text-muted: #8b8f98;

  --success: #4caf7d;
  --danger: #e2665a;

  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Login page ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(201, 162, 39, 0.08), transparent 60%),
    var(--bg-deep);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  padding: 40px 32px 32px;
}

.brand {
  text-align: center;
  margin-bottom: 8px;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 0;
}

.brand-tagline {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 4px 0 0;
}

/* Signature element: a thin light-beam that pulses under the wordmark,
   nodding to ATMAN's LED products without being literal or decorative-only. */
.light-beam {
  height: 2px;
  width: 64px;
  margin: 18px auto 28px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--amber-glow), var(--gold), transparent);
  background-size: 200% 100%;
  animation: beam-sweep 3.2s ease-in-out infinite;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .light-beam { animation: none; }
}

@keyframes beam-sweep {
  0%   { background-position: 0% 0%; opacity: 0.6; }
  50%  { background-position: 100% 0%; opacity: 1; }
  100% { background-position: 0% 0%; opacity: 0.6; }
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 11px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus {
  border-color: var(--gold);
}

.field select {
  width: 100%;
  padding: 11px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23c9a227' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  transition: border-color 0.15s ease;
}

.field select:focus {
  border-color: var(--gold);
}

.field select option {
  background: var(--surface-raised);
  color: var(--text-primary);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--gold);
  color: #14140f;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover { background: var(--amber-glow); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin: -6px 0 16px;
  min-height: 16px;
}

.login-hint {
  margin-top: 20px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

/* ---------- Dashboard shell ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border-hairline);
  padding: 24px 16px;
}

.sidebar .brand-name {
  font-size: 18px;
  text-align: left;
  margin-bottom: 2px;
}

.sidebar .brand-tagline {
  text-align: left;
  margin-bottom: 24px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 4px;
  cursor: default;
}

.nav-item.active {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-left: 2px solid var(--gold);
}

.nav-item.disabled {
  opacity: 0.45;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.main-area {
  padding: 24px 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-hairline);
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.user-chip .role-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  border: 1px solid var(--border-hairline);
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: capitalize;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.module-card {
  position: relative;
  background: linear-gradient(160deg, var(--surface-raised) 0%, var(--surface) 100%);
  border: 1px solid var(--border-hairline);
  border-radius: 16px;
  padding: 28px 24px;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--amber-glow));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.module-grid a:hover .module-card {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.module-grid a:hover .module-card::before {
  opacity: 1;
}

.module-icon {
  font-size: 32px;
  margin-bottom: 14px;
  display: inline-block;
}

.module-card h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: 0.01em;
}

.module-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 18px;
  line-height: 1.6;
}

.module-card .status-pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.status-pill {
  display: inline-block;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: 20px;
}

.status-pill.ready {
  background: rgba(76, 175, 125, 0.15);
  color: var(--success);
}

.status-pill.pending {
  background: rgba(139, 143, 152, 0.15);
  color: var(--text-muted);
}

/* ---------- Page header / actions row ---------- */

.page-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  gap: 8px;
}

.search-box input {
  padding: 9px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  min-width: 220px;
}

.btn-small {
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  background: var(--gold);
  color: #14140f;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.btn-small:hover { background: var(--amber-glow); }

.btn-ghost {
  padding: 8px 14px;
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
}

.btn-ghost:hover { border-color: var(--gold); }

.btn-danger {
  padding: 8px 14px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
}

/* ---------- Data table ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-hairline);
}

.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-hairline);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-raised); }

.row-actions { display: flex; gap: 8px; }
.row-actions button {
  background: none;
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}
.row-actions button:hover { border-color: var(--gold); color: var(--text-primary); }
.row-actions .danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Status badges ---------- */

.badge { font-size: 10px; font-family: var(--font-mono); padding: 3px 9px; border-radius: 20px; text-transform: capitalize; }
.badge.pending    { background: rgba(139,143,152,0.15); color: var(--text-muted); }
.badge.processing { background: rgba(201,162,39,0.15); color: var(--gold); }
.badge.deleted    { background: rgba(226,102,90,0.15); color: var(--danger); }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  width: 100%;
  max-width: 780px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
}

.modal-box h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0 0 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.item-row {
  display: grid;
  grid-template-columns: 2fr 70px 90px 100px 1.4fr 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.item-row-header {
  display: grid;
  grid-template-columns: 2fr 70px 90px 100px 1.4fr 32px;
  gap: 8px;
  background: #1a1a1a;
  color: #fff;
  padding: 10px;
  border-radius: 8px 8px 0 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  box-sizing: border-box;
}

#itemsContainer {
  border: 1px solid var(--border-hairline);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 0 10px;
  box-sizing: border-box;
}

#itemsContainer .item-row {
  margin-bottom: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-hairline);
  box-sizing: border-box;
}

#itemsContainer .item-row:last-child {
  border-bottom: none;
}

#itemsContainer .item-row .remove-item {
  width: 100%;
}

/* Field-level validation error state */
.field input.field-error,
.field select.field-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(226, 102, 90, 0.18);
}

/* Autocomplete widget (State / City) */
.ac-wrap {
  position: relative;
}
.ac-wrap input {
  width: 100%;
  padding: 11px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
.ac-wrap input:focus {
  border-color: var(--gold);
}
.ac-wrap.locked input {
  opacity: 0.5;
  cursor: not-allowed;
}
.ac-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  max-height: 190px;
  overflow-y: auto;
  z-index: 999;
  display: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.ac-dropdown.open {
  display: block;
}
.ac-item {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid var(--border-hairline);
}
.ac-item:last-child {
  border-bottom: none;
}
.ac-item:hover,
.ac-item.active {
  background: rgba(201, 162, 39, 0.12);
  color: var(--gold);
}
.ac-item mark {
  background: none;
  color: var(--gold);
  font-weight: 700;
}
.ac-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}
.city-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.item-row select, .item-row input {
  padding: 9px 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
}

.item-row button {
  background: none;
  border: 1px solid var(--border-hairline);
  color: var(--danger);
  border-radius: 6px;
  cursor: pointer;
  height: 34px;
}

.order-meta {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-hairline);
}

.order-meta strong { color: var(--text-primary); }

/* ---------- Notification bell ---------- */

.notif-wrap { position: relative; }

.notif-bell-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 8px 10px;
  cursor: pointer;
  font-size: 14px;
}

.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: 20px;
  display: none;
}

.notif-dropdown {
  position: absolute;
  right: 0;
  top: 44px;
  width: 300px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  display: none;
  z-index: 50;
}

.notif-dropdown.open { display: block; }

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-hairline);
  cursor: pointer;
}

.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: rgba(201,162,39,0.06); }
.notif-item p { margin: 0 0 4px; font-size: 13px; }
.notif-item span { font-size: 11px; color: var(--text-muted); }
.notif-empty { padding: 16px; font-size: 13px; color: var(--text-muted); }

/* ---------- Customer match suggestions (New Order form) ---------- */

.customer-matches {
  background: var(--surface-raised);
  border: 1px solid var(--gold);
  border-radius: 8px;
  margin: -8px 0 16px;
  max-height: 220px;
  overflow-y: auto;
}

.customer-matches-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

.customer-match-item {
  padding: 10px 12px;
  border-top: 1px solid var(--border-hairline);
  cursor: pointer;
  font-size: 13px;
}

.customer-match-item:hover { background: rgba(201,162,39,0.08); }
.customer-match-item strong { color: var(--gold); }
.customer-match-item span { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
/* ---------- Dashboard stat cards ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card.stat-card-warning {
  border-color: var(--danger);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
}

.dash-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 12px;
}

@media (max-width: 800px) {
  .dash-columns { grid-template-columns: 1fr; }
}
input.invalid {
  border-color: #b02a2a !important;
  outline-color: #b02a2a !important;
}
.totals-box {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 14px 20px;
  margin-top: 16px;
  margin-left: auto;
  max-width: 260px;
  font-size: 13px;
  color: #fff;
}
.totals-box .totals-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.totals-box .totals-row.grand {
  border-top: 1px solid #333;
  padding-top: 8px;
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
}
body.theme-light {
  --bg-deep: #f5f2ea;
  --surface: #ffffff;
  --surface-raised: #f0ede4;
  --border-hairline: #ddd7c8;
  --text-primary: #1a1a1a;
  --text-muted: #6b6b6b;
}

body.theme-light .totals-box {
  background: #1a1a1a;
  color: #fff;
}

.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.theme-toggle-btn:hover { border-color: var(--gold); }
.badge.closed { background: rgba(139,143,152,0.25); color: var(--text-muted); text-decoration: line-through; }
.payment-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.payment-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  background: var(--surface-raised);
  flex: 1;
  min-width: 100px;
}
.payment-option:has(input:checked) {
  border-color: var(--gold);
  color: var(--gold);
}