/* cartrack — dense, utilitarian UI. Gruvbox dark by default. */

:root {
  /* Text */
  --fg: #ebdbb2;
  --fg-bright: #fbf1c7;
  --fg-muted: #a89984;
  --fg-dim: #7c6f64;

  /* Backgrounds */
  --bg: #282828;
  --bg1: #3c3836;
  --bg2: #504945;
  --bg3: #665c54;
  --bg-hard: #1d2021;
  --bg-soft: #32302f;

  /* Semantic */
  --green: #b8bb26; --green-dim: #98971a;
  --red:   #fb4934; --red-dim:   #cc241d;
  --blue:  #83a598; --blue-dim:  #458588;
  --yellow: #fabd2f;
  --orange: #fe8019;
  --purple: #d3869b;
  --aqua:   #8ec07c;

  --red-bg:    #3c2828;
  --green-bg:  #3c3826;
  --blue-bg:   #2e3b3c;
  --yellow-bg: #3c3420;

  --shadow: rgba(0, 0, 0, 0.3);

  --sidebar-bg: var(--bg-hard);
}

[data-theme="light"] {
  --fg:        #3c3836;
  --fg-bright: #282828;
  --fg-muted:  #7c6f64;
  --fg-dim:    #a89984;

  --bg:       #fbf1c7;
  --bg1:      #f2e5bc;
  --bg2:      #ebdbb2;
  --bg3:      #d5c4a1;
  --bg-hard:  #f9f5d7;
  --bg-soft:  #f2e5bc;

  --green: #79740e;
  --red:   #9d0006;
  --blue:  #076678;
  --yellow: #b57614;
  --orange: #af3a03;
  --purple: #8f3f71;
  --aqua:   #427b58;

  --red-bg:    #f2d7d5;
  --green-bg:  #e5e5c1;
  --blue-bg:   #d1e3e3;
  --yellow-bg: #f0e2c0;

  --shadow: rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.85rem;
  line-height: 1.5;
}

code, .mono, td {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* Layout */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 220px;
  background: var(--sidebar-bg);
  padding: 1rem 0;
  border-right: 1px solid var(--bg2);
}

.sidebar .brand {
  padding: 0.5rem 1rem 1rem;
  font-weight: bold;
  font-size: 1rem;
  color: var(--fg-bright);
  border-bottom: 1px solid var(--bg2);
  margin-bottom: 0.5rem;
}

.sidebar nav { display: flex; flex-direction: column; }

.nav-item {
  display: block;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  color: var(--fg);
  text-decoration: none;
}
.nav-item:hover { background: var(--bg2); color: var(--fg-bright); }

main {
  margin-left: 220px;
  max-width: 960px;
  padding: 1.5rem 1rem;
}

h1 { font-size: 1.3rem; margin: 0 0 1rem; color: var(--fg-bright); }

.muted { color: var(--fg-muted); }

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--green); }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg1);
}
th {
  background: var(--bg2);
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--bg3);
}
td {
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--bg2);
}

/* Buttons */
button, .btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  background: var(--blue-dim);
  color: var(--fg-bright);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--blue); }

/* Key/value table — borderless rows, right-aligned values */
table.kv { background: transparent; max-width: 520px; }
table.kv th {
  background: transparent;
  text-align: left;
  color: var(--fg-muted);
  padding: 0.3rem 0.8rem 0.3rem 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--bg2);
  width: 40%;
}
table.kv td {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--bg2);
}

/* Four-column TPMS mini-table */
table.tpms { max-width: 420px; }
table.tpms th { text-align: center; }
table.tpms td { text-align: center; }

/* Sparkline SVG */
svg.spark {
  width: 100%;
  max-width: 640px;
  height: 140px;
  display: block;
  background: var(--bg1);
  border-radius: 4px;
  padding: 0.5rem;
  margin-bottom: 1rem;
}
svg.spark .spark-line { fill: none; stroke: var(--blue); stroke-width: 1.5; }
svg.spark .spark-avg  { stroke: var(--fg-dim); stroke-dasharray: 4 3; stroke-width: 1; }
svg.spark .spark-dots circle { fill: var(--aqua); }
svg.spark .spark-label {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.75rem;
  fill: var(--fg-muted);
}

h2 {
  font-size: 0.95rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.5rem 0 0.5rem;
}

/* Stacked form */
form.stacked { display: flex; flex-direction: column; gap: 0.6rem; max-width: 480px; }
form.stacked label { display: flex; flex-direction: column; gap: 0.2rem; color: var(--fg-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
form.stacked label.ack { flex-direction: row; align-items: center; gap: 0.5rem; text-transform: none; letter-spacing: normal; color: var(--fg); font-size: 0.85rem; }
form.stacked input[type="text"],
form.stacked input[type="number"],
form.stacked input[type="date"],
form.stacked select {
  padding: 0.5rem;
  font-size: 0.95rem;
  background: var(--bg-soft);
  border: 1px solid var(--bg2);
  color: var(--fg);
  border-radius: 4px;
}
form.stacked input:focus, form.stacked select:focus { outline: 1px solid var(--blue); outline-offset: 0; }
form.stacked button { align-self: flex-start; }

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  background: var(--bg2);
  color: var(--fg);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.btn-small:hover { background: var(--bg3); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  background: var(--bg2);
  color: var(--fg);
}
.badge.ok     { background: var(--green-bg); color: var(--green); }
.badge.muted  { background: var(--bg2);      color: var(--fg-muted); }

/* Flash / warn banners */
.flash { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow); padding: 0.5rem 0.8rem; border-radius: 4px; max-width: 640px; }
.warn  { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red);    padding: 0.5rem 0.8rem; border-radius: 4px; max-width: 640px; }

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    position: static;
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--bg2);
  }
  main { margin-left: 0; }
}
