/* Landscape Maintenance - single stylesheet, no build step. */

:root {
  color-scheme: light dark;

  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #f0f3ee;
  --border: #dfe4dc;
  --text: #1b2419;
  --muted: #63705e;
  --accent: #2f6d3f;
  --accent-soft: #e4efe4;
  --overdue: #b3261e;
  --today: #b26a00;
  --soon: #2f6d3f;
  --shadow: 0 1px 2px rgba(20, 32, 18, .06), 0 6px 18px rgba(20, 32, 18, .05);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131714;
    --surface: #1b211c;
    --surface-2: #222a23;
    --border: #2f3a30;
    --text: #e6ece4;
    --muted: #9aa896;
    --accent: #6fbf7f;
    --accent-soft: #23331f;
    --overdue: #f2837b;
    --today: #e0a850;
    --soon: #6fbf7f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .5rem; }

a { color: var(--accent); }

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 1rem; top: 1rem; z-index: 50;
  background: var(--surface); padding: .5rem .75rem; border-radius: 8px;
}

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

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

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .95rem;
}
.brand-mark { font-size: 1.5rem; }
.brand-text { line-height: 1.2; color: var(--muted); }
.brand-text strong { color: var(--text); font-size: 1.05rem; }

.menu-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.1rem;
  padding: .25rem .55rem;
  cursor: pointer;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .7rem;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-icon { width: 1.1rem; text-align: center; opacity: .85; }

.sidebar-foot {
  margin-top: auto;
  font-size: .75rem;
  color: var(--muted);
}

.view {
  padding: 1.75rem clamp(1rem, 3vw, 2.25rem) 3rem;
  max-width: 1180px;
  width: 100%;
  outline: none;
}

.view-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.warn { color: var(--overdue); font-weight: 600; }

/* ------------------------------------------------------------------ cards */

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

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.stat.overdue { border-left-color: var(--overdue); }
.stat.today { border-left-color: var(--today); }
.stat.soon { border-left-color: var(--soon); }
.stat.issue { border-left-color: var(--muted); }
.stat-value { font-size: 1.9rem; font-weight: 650; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .82rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .85rem;
}
.link { font-size: .85rem; text-decoration: none; }
.link:hover { text-decoration: underline; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tag {
  background: var(--surface-2);
  border-radius: 999px;
  color: var(--muted);
  font-size: .72rem;
  padding: .15rem .6rem;
  white-space: nowrap;
}
.card-facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem .75rem;
  margin: 0;
}
.card-facts.wide { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.card-facts dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.card-facts dd { margin: 0; font-weight: 600; }
.card-actions { display: flex; gap: .4rem; margin-top: auto; padding-top: .3rem; }

/* ------------------------------------------------------------------ lists */

.task-list, .issue-list, .bar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.task {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .7rem 0;
  border-top: 1px solid var(--border);
}
.task:first-child { border-top: none; }
.task-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.task-main span { font-size: .82rem; }
.task-due { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }

.pill {
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  padding: .12rem .55rem;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}
.pill.overdue { background: color-mix(in srgb, var(--overdue) 15%, transparent); color: var(--overdue); }
.pill.today { background: color-mix(in srgb, var(--today) 18%, transparent); color: var(--today); }
.pill.soon { background: var(--accent-soft); color: var(--accent); }
.pill.sev-high { background: color-mix(in srgb, var(--overdue) 15%, transparent); color: var(--overdue); }
.pill.sev-medium { background: color-mix(in srgb, var(--today) 18%, transparent); color: var(--today); }
.pill.sev-low { background: var(--surface-2); color: var(--muted); }

.bar-list li {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 3fr auto;
  align-items: center;
  gap: .75rem;
  padding: .3rem 0;
}
.bar-label { font-size: .85rem; }
.bar { background: var(--surface-2); border-radius: 999px; height: 8px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-value { font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--muted); }

.meter-row { display: flex; align-items: center; gap: .8rem; margin-bottom: .5rem; }
.meter { flex: 1; background: var(--surface-2); border-radius: 999px; height: 10px; overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--accent); }
.meter-fill.low { background: var(--today); }

.issue {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: .85rem 0;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.issue:first-child { border-top: none; }
.issue.closed { opacity: .62; }
.issue-main { display: flex; flex-direction: column; gap: .25rem; min-width: 0; flex: 1 1 320px; }
.issue-title { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.issue-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ----------------------------------------------------------------- tables */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.table { border-collapse: collapse; width: 100%; min-width: 880px; }
.table th, .table td {
  padding: .65rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: none; }
/* Keep zone and crew names on one or two lines rather than one word per line. */
.table-schedule td:nth-child(2), .table-schedule td:nth-child(4) { min-width: 9rem; }
.table tbody tr:hover { background: var(--surface-2); }

/* ------------------------------------------------------- forms & controls */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1rem;
  align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; }
.field > span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.field small { color: var(--muted); font-size: .75rem; }
.field.inline { margin-bottom: 0; min-width: 150px; }
.field.grow { flex: 1 1 220px; }
.field.check { flex-direction: row; align-items: center; flex-wrap: wrap; gap: .5rem; }
.field.check input { width: auto; }
.field.check > span { font-size: .85rem; color: var(--text); font-weight: 500; }
.field.check small { flex-basis: 100%; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .45rem .6rem;
  width: 100%;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 1rem;
}

.btn {
  font: inherit;
  font-weight: 550;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: .45rem .85rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--overdue); border-color: color-mix(in srgb, var(--overdue) 40%, var(--border)); }
.btn.danger:hover { background: color-mix(in srgb, var(--overdue) 10%, transparent); }
.btn.small { padding: .25rem .55rem; font-size: .8rem; }
.button-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.2rem 1rem;
  text-align: center;
  color: var(--muted);
}
.empty p { margin-bottom: .9rem; }

/* ----------------------------------------------------------------- dialog */

.dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 1.25rem 1.4rem;
  width: min(520px, calc(100vw - 2rem));
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
}
.dialog::backdrop { background: rgba(15, 22, 14, .45); }
.dialog h2 { margin-bottom: 1rem; }
.dialog-body { max-height: 62vh; overflow-y: auto; }
.dialog-error { color: var(--overdue); font-size: .85rem; min-height: 1.2em; margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .8rem; }

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translate(-50%, 150%);
  background: var(--text);
  color: var(--bg);
  padding: .6rem 1.1rem;
  border-radius: 999px;
  font-size: .88rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  opacity: 0;
  visibility: hidden;
  transition: transform .22s ease, opacity .22s ease, visibility .22s;
  z-index: 40;
  max-width: calc(100vw - 2rem);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: .8rem 1rem;
    gap: .8rem;
  }
  .menu-toggle { display: block; }
  .nav { display: none; }
  .nav.open { display: flex; }
  .sidebar-foot { display: none; }
  .view { padding: 1.25rem 1rem 3rem; }
  .task { flex-wrap: wrap; }
  .task-due { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
