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

:root {
  --accent:      #fb923c;
  --accent-dim:  rgba(251,146,60,0.12);
  --accent-glow: rgba(251,146,60,0.15);
  --danger:      #f87171;
  --warning:     #facc15;
  --warn-dim:    rgba(250,204,21,0.10);
  --success:     #4ade80;
  --info:        #38bdf8;
  --bg:          #0f0b08;
  --bg-card:     #160e08;
  --bg-hover:    #1c1208;
  --border:      #2a1e10;
  --text:        #fff0e8;
  --text-2:      #b08060;
  --text-3:      #6a4830;
  --font-mono:   'Consolas','Cascadia Code','Fira Code','Courier New',monospace;
  --font-body:   -apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif;
  --radius:      8px;
  --radius-lg:   12px;
}

html { font-size: 16px; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: linear-gradient(rgba(251,146,60,0.025) 1px,transparent 1px), linear-gradient(90deg,rgba(251,146,60,0.025) 1px,transparent 1px);
  background-size: 40px 40px;
}
.bg-glow {
  position: fixed; top: -15vh; left: 50%; transform: translateX(-50%);
  width: 70vw; height: 50vh; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
}

.app-layout { display: flex; flex-direction: column; min-height: 100vh; position: relative; z-index: 1; }
.site-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 52px;
  background: rgba(15,11,8,0.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 1.25rem; }
.logo { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.logo-text { font-family: var(--font-mono); font-size: 0.88rem; font-weight: 600; color: var(--text); letter-spacing: 0.04em; }
.logo-sub { font-size: 0.6rem; color: var(--accent); font-family: var(--font-mono); }
.nav-tabs { display: flex; gap: 0.15rem; }
.nav-tab {
  padding: 0.3rem 0.85rem; border-radius: 6px;
  font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.04em;
  color: var(--text-2); background: none; border: none; cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.nav-tab:hover { color: var(--text); background: var(--bg-hover); }
.nav-tab.active { color: var(--accent); background: var(--accent-dim); }
.header-right { display: flex; align-items: center; gap: 0.5rem; }

main { flex: 1; padding: 1.5rem; max-width: 1280px; margin: 0 auto; width: 100%; }
.site-footer { border-top: 1px solid var(--border); padding: 1rem 1.5rem; font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-3); text-align: center; }
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 1rem; border-radius: var(--radius); font-size: 0.85rem; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; transition: all 0.15s; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.btn-primary:hover { background: rgba(251,146,60,0.22); }
.btn-ghost { background: none; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: var(--text-3); }
.btn-danger { background: rgba(248,113,113,0.1); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.btn-icon { padding: 0.35rem; border-radius: 6px; background: none; border: 1px solid var(--border); color: var(--text-2); cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
}
.stat-card.accent  { border-color: var(--accent); background: var(--accent-dim); }
.stat-card.warning { border-color: var(--warning); background: var(--warn-dim); }
.stat-card.danger  { border-color: var(--danger);  background: rgba(248,113,113,0.08); }
.stat-card.success { border-color: #4ade80; background: rgba(74,222,128,0.08); }
.stat-label { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.4rem; }
.stat-value { font-family: var(--font-mono); font-size: 1.8rem; font-weight: 700; color: var(--text); }
.stat-card.accent .stat-value  { color: var(--accent); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value  { color: var(--danger); }
.stat-card.success .stat-value { color: #4ade80; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-title { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.08em; }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.card-header { padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 0.75rem; }
.card-title { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 600; color: var(--text); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  padding: 0.65rem 1rem; text-align: left;
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 0.75rem 1rem; vertical-align: middle; }

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.55rem; border-radius: 4px; font-size: 0.72rem; font-weight: 600;
  font-family: var(--font-mono); white-space: nowrap;
}
.badge-active   { background: rgba(74,222,128,0.1);  color: #4ade80; border: 1px solid rgba(74,222,128,0.25); }
.badge-overdue  { background: rgba(248,113,113,0.1);  color: var(--danger);  border: 1px solid rgba(248,113,113,0.25); }
.badge-due-soon { background: var(--warn-dim);        color: var(--warning); border: 1px solid rgba(250,204,21,0.3); }
.badge-ok       { background: rgba(56,189,248,0.1);   color: #38bdf8; border: 1px solid rgba(56,189,248,0.25); }
.badge-inactive { background: rgba(176,128,96,0.1);   color: var(--text-2); border: 1px solid var(--border); }

.badge-cnc      { background: rgba(251,146,60,0.1);  color: #fb923c; }
.badge-truck    { background: rgba(56,189,248,0.1);  color: #38bdf8; }
.badge-forklift { background: rgba(250,204,21,0.1);  color: #facc15; }
.badge-other    { background: rgba(176,128,96,0.1);  color: #b08060; }

.filters { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-select, .filter-input {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 0.4rem 0.75rem; font-size: 0.83rem;
  font-family: var(--font-body); outline: none; transition: border-color 0.15s;
}
.filter-select:focus, .filter-input:focus { border-color: var(--accent); }
.filter-input { min-width: 200px; }
.filter-input::placeholder { color: var(--text-3); }
.filters-spacer { flex: 1; }

.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 580px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal-lg { max-width: 800px; }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--bg-card); z-index: 10; }
.modal-title { font-family: var(--font-mono); font-weight: 600; font-size: 0.95rem; }
.modal-close { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 1.2rem; padding: 0.2rem; border-radius: 4px; transition: color 0.15s; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; justify-content: flex-end; position: sticky; bottom: 0; background: var(--bg-card); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }
.form-input, .form-select, .form-textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 0.55rem 0.75rem; font-size: 0.88rem;
  font-family: var(--font-body); outline: none; transition: border-color 0.15s; width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.75rem; color: var(--text-3); }

.notice { padding: 0.65rem 0.9rem; border-radius: var(--radius); font-size: 0.83rem; margin-bottom: 1rem; }
.notice-danger  { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--danger); }
.notice-success { background: rgba(74,222,128,0.1);  border: 1px solid rgba(74,222,128,0.3);  color: #4ade80; }
.notice-warning { background: var(--warn-dim); border: 1px solid rgba(250,204,21,0.3); color: var(--warning); }
.hidden { display: none !important; }

.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-3); }
.empty-state svg { opacity: 0.3; margin-bottom: 1rem; }
.empty-state p { font-size: 0.9rem; }

tr.row-overdue  { border-left: 3px solid var(--danger); }
tr.row-due-soon { border-left: 3px solid var(--warning); }
tr.row-ok       { border-left: 3px solid #4ade80; }

.upcoming-list { display: flex; flex-direction: column; gap: 0.5rem; }
.upcoming-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem 1rem; display: flex; align-items: center; gap: 1rem;
}
.upcoming-item.overdue { border-left: 3px solid var(--danger); }
.upcoming-item.soon    { border-left: 3px solid var(--warning); }
.upcoming-item.ok      { border-left: 3px solid #4ade80; }
.upcoming-name  { font-weight: 500; font-size: 0.9rem; flex: 1; }
.upcoming-meta  { font-size: 0.8rem; color: var(--text-2); }
.upcoming-date  { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-3); white-space: nowrap; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* Service history */
.service-log { display: flex; flex-direction: column; gap: 0; }
.service-entry {
  padding: 0.9rem 1rem; border-bottom: 1px solid var(--border); position: relative;
}
.service-entry:last-child { border-bottom: none; }
.service-entry-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.3rem; }
.service-entry-date { font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent); }
.service-entry-type { font-size: 0.75rem; color: var(--text-2); }
.service-entry-desc { font-size: 0.88rem; color: var(--text); }
.service-entry-meta { font-size: 0.78rem; color: var(--text-3); margin-top: 0.2rem; }
.service-entry-del  { position: absolute; top: 0.75rem; right: 1rem; opacity: 0; transition: opacity 0.15s; }
.service-entry:hover .service-entry-del { opacity: 1; }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Auth layout ── */
.auth-layout { display: grid; grid-template-columns: 1fr 420px; flex: 1 0 auto; min-height: 0; width: 100%; max-width: 1360px; margin: 0 auto; padding: 3rem 2rem; gap: 0 4rem; align-items: start; align-content: start; position: relative; z-index: 1; }
.auth-hero { display: contents; }
.auth-logo { grid-column: 1; display: flex; align-items: center; gap: 0.6rem; text-decoration: none; margin-bottom: 2.5rem; }
.auth-logo-name { font-size: 1rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.auth-logo-sub { color: var(--text-3); font-weight: 400; }
.auth-tagline { grid-column: 1; }
.auth-tagline h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; line-height: 1.15; letter-spacing: -0.03em; color: var(--text); margin-bottom: 0.75rem; }
.auth-tagline p { font-size: 1rem; color: var(--text-2); line-height: 1.6; max-width: 40ch; }
.auth-right { grid-column: 2; grid-row: 3; margin-top: 2.5rem; display: flex; flex-direction: column; }
.auth-card-wrap { flex: 1; display: flex; align-items: flex-start; padding: 0 0 3rem; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; width: 100%; }
.auth-card-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 1.5rem; letter-spacing: -0.01em; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-card-footer { margin-top: 1.25rem; font-size: 0.82rem; color: var(--text-3); text-align: center; }
.auth-link { color: var(--accent); text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-footer { padding: 1.25rem 0; border-top: 1px solid var(--border); text-align: center; }
.auth-footer-line { font-size: 0.78rem; color: var(--text-3); margin-bottom: 0.4rem; }
.auth-footer-line a { color: inherit; text-decoration: none; }
.auth-footer-links { display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.auth-footer-link { font-size: 0.78rem; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; gap: 3px; }
.auth-footer-link:hover { opacity: 0.75; }
.auth-footer-sep { color: var(--text-3); }
.auth-preview { grid-column: 1; margin-top: 2.5rem; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-card); box-shadow: 0 8px 40px rgba(0,0,0,0.5); position: relative; }
.auth-preview::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 60px; background: linear-gradient(transparent, var(--bg-card)); pointer-events: none; z-index: 1; }
.auth-preview-bar { background: rgba(0,0,0,0.35); border-bottom: 1px solid var(--border); padding: 0.5rem 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.auth-preview-dots { display: flex; gap: 5px; }
.auth-preview-dots span { width: 9px; height: 9px; border-radius: 50%; display: block; }
.auth-preview-dots span:nth-child(1) { background: #ef4444; }
.auth-preview-dots span:nth-child(2) { background: #f59e0b; }
.auth-preview-dots span:nth-child(3) { background: #22c55e; }
.auth-preview-addr { flex: 1; text-align: center; font-size: 0.68rem; color: var(--text-3); font-family: var(--font-mono); }
.auth-preview-body { padding: 0.85rem; }
.auth-preview-toprow { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.65rem; }
.auth-preview-tablabel { font-size: 0.78rem; font-weight: 600; color: var(--text); }
.auth-preview-tabcount { font-size: 0.67rem; color: var(--text-3); font-family: var(--font-mono); background: rgba(255,255,255,0.04); padding: 0.15rem 0.5rem; border-radius: 10px; border: 1px solid var(--border); }
.auth-preview-table { width: 100%; border-collapse: collapse; }
.auth-preview-table th { color: var(--text-3); font-weight: 600; text-transform: uppercase; font-size: 0.6rem; letter-spacing: 0.06em; padding: 0.3rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
.auth-preview-table td { padding: 0.38rem 0.5rem; font-size: 0.71rem; color: var(--text-2); border-bottom: 1px solid rgba(255,255,255,0.03); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-preview-table tr:last-child td { border-bottom: none; }
.ap-badge { display: inline-block; font-size: 0.59rem; font-family: var(--font-mono); padding: 0.1rem 0.45rem; border-radius: 3px; }
.ap-valid { background: rgba(74,222,128,0.1); color: #4ade80; border: 1px solid rgba(74,222,128,0.2); }
.ap-warn  { background: rgba(234,179,8,0.1); color: #eab308; border: 1px solid rgba(234,179,8,0.2); }
.ap-crit  { background: rgba(239,68,68,0.1); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.ap-gray  { background: rgba(148,163,184,0.1); color: #94a3b8; border: 1px solid rgba(148,163,184,0.2); }
@media (max-width: 880px) {
  .auth-layout { grid-template-columns: 1fr; max-width: 480px; padding: 0 1.25rem; }
  .auth-hero { display: flex; flex-direction: column; padding: 2rem 0 0.5rem; }
  .auth-logo { grid-column: unset; }
  .auth-tagline { grid-column: unset; }
  .auth-preview { display: none; }
  .auth-right { grid-column: 1; grid-row: auto; margin-top: 0; }
  .auth-card-wrap { padding: 1.25rem 0 1.5rem; align-items: center; }
}

.sortable-th { cursor:pointer; user-select:none; white-space:nowrap; }
.sortable-th:hover { color:var(--text); }
.sort-indicator { font-size:0.65em; opacity:0.4; margin-left:2px; }
.sort-indicator.asc::after { content:'↑'; opacity:1; color:var(--accent); }
.sort-indicator.desc::after { content:'↓'; opacity:1; color:var(--accent); }
