/* =====================================================================
   AUTO MATRIX GLOBAL — Admin Panel
   Same material language as the site, tuned for density and speed.
   ===================================================================== */

:root {
  --carbon:    #0B0C0F;
  --graphite:  #121419;
  --slate:     #191C23;
  --raise:     #21252E;
  --line:      rgba(255,255,255,.08);
  --line-soft: rgba(255,255,255,.045);
  --chalk:     #EEF1F5;
  --steel:     #878E9F;
  --dim:       #5A6070;
  --film:      #9FE8FF;
  --film-deep: #4EC3E8;
  --irid: linear-gradient(90deg, #7FE7FF, #A99BFF 34%, #FF8FB1 66%, #FFCF7A);
  --success: #4ADE9B;
  --warn:    #F5C451;
  --danger:  #FF6B5A;
  --display: 'Archivo', sans-serif;
  --body:    'Instrument Sans', system-ui, sans-serif;
  --mono:    'JetBrains Mono', monospace;
  --ease: cubic-bezier(.19,1,.22,1);
  --sidebar: 258px;
}

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

body {
  background: var(--carbon);
  color: var(--chalk);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--film); outline-offset: 2px; }
::selection { background: var(--film); color: var(--carbon); }

/* ── Login ───────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(50% 44% at 70% 22%, rgba(78,195,232,.14), transparent 65%),
    radial-gradient(40% 40% at 22% 80%, rgba(169,155,255,.09), transparent 68%),
    var(--carbon);
}
.login-card {
  width: min(430px, 100%);
  background: var(--graphite);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2.4rem;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--irid);
}
.login-mark {
  width: 40px; height: 40px;
  border-radius: 3px;
  background: var(--irid);
  display: grid;
  place-items: center;
  margin-bottom: 1.6rem;
  position: relative;
}
.login-mark::after { content: ''; position: absolute; inset: 1px; background: var(--carbon); border-radius: 2px; }
.login-mark span {
  position: relative; z-index: 2;
  font-family: var(--display); font-weight: 800; font-size: 1rem; letter-spacing: -.04em;
}
.login-title {
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 112%;
  font-size: 1.6rem;
  text-transform: uppercase;
  letter-spacing: -.025em;
  line-height: 1;
  margin-bottom: .5rem;
}
.login-sub { color: var(--steel); font-size: .9rem; margin-bottom: 2rem; }
.login-hint {
  margin-top: 1.6rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .1em;
  color: var(--dim);
  line-height: 1.8;
}

/* ── Shell ───────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
@media (min-width: 1000px) { .shell { grid-template-columns: var(--sidebar) 1fr; } }

.sidebar {
  background: var(--graphite);
  border-right: 1px solid var(--line);
  padding: 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
@media (max-width: 999px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    z-index: 60;
    transform: translateX(-102%);
    transition: transform .45s var(--ease);
  }
  .sidebar.open { transform: none; }
}

.side-brand { display: flex; align-items: center; gap: .7rem; padding: .4rem .5rem 1.2rem; border-bottom: 1px solid var(--line); }
.side-mark {
  width: 32px; height: 32px; flex: none;
  border-radius: 3px; background: var(--irid);
  position: relative; display: grid; place-items: center;
}
.side-mark::after { content: ''; position: absolute; inset: 1px; background: var(--graphite); border-radius: 2px; }
.side-mark span { position: relative; z-index: 2; font-family: var(--display); font-weight: 800; font-size: .82rem; }
.side-name { font-family: var(--display); font-weight: 800; font-stretch: 110%; font-size: .95rem; text-transform: uppercase; letter-spacing: -.02em; line-height: 1.1; }
.side-role { font-family: var(--mono); font-size: .56rem; letter-spacing: .18em; text-transform: uppercase; color: var(--dim); }

.nav-group { display: grid; gap: .15rem; }
.nav-label {
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--dim);
  padding: .9rem .6rem .5rem;
}
.side-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .62rem .65rem;
  border-radius: 3px;
  font-size: .88rem;
  color: var(--steel);
  transition: background .25s ease, color .25s ease;
  position: relative;
}
.side-link:hover { background: var(--slate); color: var(--chalk); }
.side-link.active { background: var(--slate); color: var(--chalk); }
.side-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 2px;
  background: var(--irid);
  border-radius: 2px;
}
.side-link svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.side-badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .6rem;
  padding: .1rem .4rem;
  border-radius: 20px;
  background: var(--film);
  color: var(--carbon);
}
.side-foot { margin-top: auto; padding-top: 1.2rem; border-top: 1px solid var(--line); }

.scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden;
  transition: opacity .3s ease, visibility .3s;
}
.scrim.show { opacity: 1; visibility: visible; }
@media (min-width: 1000px) { .scrim { display: none; } }

/* ── Main ────────────────────────────────────────────────────────── */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem clamp(1rem, 3vw, 2rem);
  background: rgba(11,12,15,.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.top-title { font-family: var(--display); font-weight: 800; font-stretch: 108%; font-size: 1.1rem; text-transform: uppercase; letter-spacing: -.02em; }
.top-sub { font-family: var(--mono); font-size: .6rem; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }

.hamburger {
  width: 38px; height: 38px;
  display: grid; place-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: 3px;
}
@media (min-width: 1000px) { .hamburger { display: none; } }
.hamburger i { width: 15px; height: 1.5px; background: var(--chalk); display: block; }

.page { padding: clamp(1.2rem, 3vw, 2rem); display: grid; gap: 1.4rem; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .62rem 1.05rem;
  background: var(--chalk);
  color: var(--carbon);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: transform .3s var(--ease), opacity .25s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); opacity: .9; }
.btn--ghost { background: transparent; color: var(--chalk); box-shadow: inset 0 0 0 1px var(--line); }
.btn--ghost:hover { box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.btn--danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px rgba(255,107,90,.35); }
.btn--danger:hover { background: rgba(255,107,90,.1); }
.btn--sm { padding: .42rem .8rem; font-size: .64rem; }

/* ── Cards & panels ──────────────────────────────────────────────── */
.panel {
  background: var(--graphite);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 1.3rem;
  border-bottom: 1px solid var(--line);
}
.panel-title { font-family: var(--display); font-weight: 800; font-stretch: 106%; font-size: .98rem; text-transform: uppercase; letter-spacing: -.015em; }
.panel-body { padding: 1.3rem; }
.panel-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat {
  background: var(--graphite);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1.3rem;
  position: relative;
  overflow: hidden;
  transition: border-color .35s ease, transform .5s var(--ease);
}
.stat:hover { border-color: rgba(255,255,255,.18); transform: translateY(-3px); }
.stat::before { content: ''; position: absolute; inset: 0 0 auto; height: 1px; background: var(--irid); transform: scaleX(0); transform-origin: left; transition: transform .6s var(--ease); }
.stat:hover::before { transform: scaleX(1); }
.stat-label { font-family: var(--mono); font-size: .6rem; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); margin-bottom: .9rem; }
.stat-value { font-family: var(--display); font-weight: 800; font-stretch: 104%; font-size: 2rem; line-height: 1; letter-spacing: -.03em; }
.stat-note { font-size: .78rem; color: var(--steel); margin-top: .5rem; }

/* ── Tables ──────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 640px; }
th {
  text-align: left;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 400;
  padding: .85rem 1.3rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: .95rem 1.3rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr { transition: background .25s ease; }
tbody tr:hover { background: var(--slate); }
tbody tr:last-child td { border-bottom: 0; }
td .sub { color: var(--dim); font-size: .78rem; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
.cell-strong { font-weight: 600; }

/* ── Status chips ────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: .28rem .6rem;
  border-radius: 20px;
  border: 1px solid;
  white-space: nowrap;
}
.chip::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip--new       { color: var(--film);    border-color: rgba(159,232,255,.3); background: rgba(159,232,255,.08); }
.chip--contacted { color: #A99BFF;        border-color: rgba(169,155,255,.3); background: rgba(169,155,255,.08); }
.chip--quoted    { color: var(--warn);    border-color: rgba(245,196,81,.3);  background: rgba(245,196,81,.08); }
.chip--booked    { color: #FF8FB1;        border-color: rgba(255,143,177,.3); background: rgba(255,143,177,.08); }
.chip--completed { color: var(--success); border-color: rgba(74,222,155,.3);  background: rgba(74,222,155,.08); }
.chip--lost      { color: var(--dim);     border-color: var(--line);          background: transparent; }
.chip--on        { color: var(--success); border-color: rgba(74,222,155,.3);  background: rgba(74,222,155,.08); }
.chip--off       { color: var(--dim);     border-color: var(--line);          background: transparent; }
.chip--pending   { color: var(--warn);    border-color: rgba(245,196,81,.3);  background: rgba(245,196,81,.08); }
.chip--approved  { color: var(--success); border-color: rgba(74,222,155,.3);  background: rgba(74,222,155,.08); }
.chip--rejected  { color: var(--danger);  border-color: rgba(255,107,90,.3);  background: rgba(255,107,90,.08); }

/* ── Pipeline board ──────────────────────────────────────────────── */
.pipeline { display: grid; gap: .6rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 1100px) { .pipeline { grid-template-columns: repeat(6, 1fr); } }
.pipe-col {
  background: var(--graphite);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1rem;
  text-align: center;
  transition: border-color .3s ease, background .3s ease;
}
.pipe-col:hover { border-color: rgba(255,255,255,.16); background: var(--slate); }
.pipe-n { font-family: var(--display); font-weight: 800; font-size: 1.7rem; line-height: 1; letter-spacing: -.03em; }
.pipe-l { font-family: var(--mono); font-size: .58rem; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin-top: .5rem; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-grid { display: grid; gap: 1rem; }
.cols-2 { display: grid; gap: 1rem; }
.cols-3 { display: grid; gap: 1rem; }
@media (min-width: 760px) { .cols-2 { grid-template-columns: repeat(2, 1fr); } .cols-3 { grid-template-columns: repeat(3, 1fr); } }

.field { display: grid; gap: .42rem; }
.field label { font-family: var(--mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; color: var(--steel); }
.field input, .field select, .field textarea {
  background: var(--slate);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: .68rem .8rem;
  font-size: .9rem;
  width: 100%;
  transition: border-color .25s ease, background .25s ease;
}
.field textarea { min-height: 110px; resize: vertical; font-family: var(--body); }
.field textarea.lines { font-family: var(--mono); font-size: .82rem; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--film-deep); background: var(--raise); }
.field select option { background: var(--slate); }
.field .hint { font-size: .74rem; color: var(--dim); }
.field-inline { display: flex; align-items: center; gap: .6rem; }
.field-inline input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--film-deep); }

.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.toolbar .field { flex: 1 1 180px; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: 3px;
  border: 1px solid;
  font-size: .87rem;
}
.alert--success { color: #B6F3D6; border-color: rgba(74,222,155,.32); background: rgba(74,222,155,.08); }
.alert--error   { color: #FFC5BD; border-color: rgba(255,107,90,.32); background: rgba(255,107,90,.08); }
.alert--info    { color: #C7E9F5; border-color: rgba(159,232,255,.28); background: rgba(159,232,255,.06); }

/* ── Timeline (lead notes) ───────────────────────────────────────── */
.timeline { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 12px 1fr; gap: 1rem; padding-bottom: 1.4rem; position: relative; }
.tl-item::before { content: ''; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 1px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--slate); border: 1px solid var(--film-deep); margin-top: 5px; }
.tl-meta { font-family: var(--mono); font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-bottom: .25rem; }
.tl-text { font-size: .89rem; color: var(--chalk); }

/* ── Misc ────────────────────────────────────────────────────────── */
.empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--dim);
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.thumb { width: 52px; height: 40px; object-fit: cover; border-radius: 3px; border: 1px solid var(--line); }
.thumb-empty { width: 52px; height: 40px; border-radius: 3px; border: 1px dashed var(--line); }
.split-2 { display: grid; gap: 1.4rem; }
@media (min-width: 1050px) { .split-2 { grid-template-columns: 1.6fr 1fr; align-items: start; } }
.muted { color: var(--steel); }
.mono { font-family: var(--mono); font-size: .74rem; letter-spacing: .1em; }
.stack-sm { display: grid; gap: .5rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 1.6rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ── Light Theme Overrides ───────────────────────────────────────── */
html.light-theme {
  --carbon:    #f6f8fa;
  --graphite:  #ffffff;
  --slate:     #eff2f5;
  --raise:     #ffffff;
  --line:      rgba(0, 0, 0, .08);
  --line-soft: rgba(0, 0, 0, .045);
  --chalk:     #111827;
  --steel:     #4b5563;
  --dim:       #6b7280;
  --film:      #0b7a99;
  --film-deep: #086078;
}

html.light-theme body {
  background: var(--carbon);
  color: var(--chalk);
}

/* Sidebar override for light theme */
html.light-theme .sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
}
html.light-theme .side-brand::after {
  background: #ffffff;
}

/* Scrim override */
html.light-theme .scrim {
  background: rgba(0,0,0,.15);
}

/* Topbar override */
html.light-theme .topbar {
  background: rgba(246, 248, 250, .85);
  border-bottom: 1px solid var(--line);
}

/* Input fields hover/focus override in admin */
html.light-theme input:hover, 
html.light-theme select:hover, 
html.light-theme textarea:hover {
  border-color: rgba(0, 0, 0, .24);
}
html.light-theme input:focus, 
html.light-theme select:focus, 
html.light-theme textarea:focus {
  background: #ffffff;
  border-color: var(--film-deep);
}

/* Alerts overrides for readability */
html.light-theme .alert--success { color: #155724; border-color: rgba(74,222,155,.6); background: rgba(74,222,155,.1); }
html.light-theme .alert--error   { color: #721c24; border-color: rgba(255,107,90,.6); background: rgba(255,107,90,.1); }
html.light-theme .alert--info    { color: #0c5460; border-color: rgba(159,232,255,.5); background: rgba(159,232,255,.1); }

/* Table hover row override */
html.light-theme tbody tr:hover {
  background: var(--slate);
}

/* Scrollbars in light mode */
html.light-theme ::-webkit-scrollbar-track { background: var(--carbon); }
html.light-theme ::-webkit-scrollbar-thumb { background: var(--line); }
html.light-theme ::-webkit-scrollbar-thumb:hover { background: var(--steel); }
