/* Ladonos -- hand-written design system.
   No build step, no CDN, no framework upgrade treadmill. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #14181f;
  --muted: #667085;
  --accent: #1c6fd4;
  --accent-soft: #e8f1fc;
  --ok: #067a52;
  --ok-soft: #e3f5ee;
  --warn: #9a5b00;
  --warn-soft: #fdf1de;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --surface: #171b21; --border: #262c35; --text: #e6e9ee;
    --muted: #98a2b3; --accent: #61a5f2; --accent-soft: #16283f;
    --ok: #4ade80; --ok-soft: #10261c; --warn: #fbbf5a; --warn-soft: #2a1f0d;
    --danger: #f97066; --danger-soft: #2d1513;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 650; letter-spacing: -.01em; }
.brand span { color: var(--muted); font-weight: 400; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 24px 64px; }

h1 { font-size: 22px; letter-spacing: -.02em; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

/* ---- Stat tiles ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---- Card + table ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 16px; border-bottom: 1px solid var(--border); }
td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-soft); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---- Controls ---- */
input[type=search], input[type=text], input[type=email], input[type=password], select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=search] { min-width: 240px; }

.btn { font: inherit; font-weight: 500; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 550; }
.badge-active { background: var(--ok-soft); color: var(--ok); }
.badge-inactive { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge-suspended { background: var(--warn-soft); color: var(--warn); }
.badge-returned { background: var(--danger-soft); color: var(--danger); }

/* ---- Tenant switcher ---- */
.tenant-switch { display: flex; gap: 6px; align-items: center; }
.tenant-switch a { padding: 4px 10px; border-radius: 6px; font-size: 13px; color: var(--muted); }
.tenant-switch a.current { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.tenant-switch a:hover { text-decoration: none; background: var(--accent-soft); }

/* ---- Login ---- */
.login-wrap { max-width: 360px; margin: 12vh auto; }
.login-wrap .card { padding: 28px; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 550; }
.field input { width: 100%; }
.errors { background: var(--danger-soft); color: var(--danger); padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }

/* ---- Detail ---- */
.back { font-size: 13px; color: var(--muted); }
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 18px; padding: 18px 16px; }
.dl div { display: flex; flex-direction: column; gap: 3px; }
.dl dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.dl dd { margin: 0; font-size: 15px; }

/* ---- Fleet map ---- */
.map-card { margin-bottom: 24px; position: relative; }
#fleet-map { height: 420px; width: 100%; background: var(--bg); }
#fleet-map:focus { outline: none; }
.map-empty {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--muted); font-size: 14px; pointer-events: none; z-index: 2;
}
.map-empty.show { display: flex; }
.maplibregl-popup-content {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 10px 12px; font: inherit; font-size: 13px;
}
.maplibregl-popup-content .serial { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; }
.maplibregl-popup-content .meta { color: var(--muted); margin: 3px 0 6px; }
.maplibregl-popup-tip { border-top-color: var(--border) !important; border-bottom-color: var(--border) !important; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 16px; padding: 0 5px; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* ---- Sign-in alternatives ---- */
.or { display: flex; align-items: center; gap: 12px; margin: 20px 0 16px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-social { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; text-decoration: none; }
.btn-social:hover { text-decoration: none; background: var(--accent-soft); }
.sso-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.sso-form .field { margin-bottom: 10px; }
