/*
  Design plan (kept here so future edits stay consistent):

  Color   — grounded in the subject, not a generic SaaS palette:
            blueprint navy (#1B3A4B) for structure/brand, safety orange
            (#E85D25) for primary actions and accents, a warm paper/concrete
            background rather than pure white, status colors kept distinct
            from the brand colors so they read clearly at a glance.
  Type    — one system sans-serif stack (fast, and works with zero network,
            which matters for an offline-first field app), one clear scale,
            weight does the differentiating rather than a second typeface.
  Layout  — left-aligned, functional. Thin 1px rules instead of drop
            shadows (a technical/blueprint feel rather than the generic
            soft-shadow card kit). Status is shown with a left accent bar
            on list rows, not just a badge, so a scanned list is readable
            from status color alone.
  Principle — large tap targets and minimal chrome throughout, since this
            is used one-handed, outdoors, on a job site.
*/

:root {
  --navy: #1B3A4B;
  --navy-dark: #12262F;
  --orange: #E85D25;
  --orange-dark: #C94E1C;
  --bg: #F3F1EA;
  --surface: #FFFFFF;
  --ink: #22282C;
  --ink-soft: #5B646B;
  --border: #DDD8CE;
  --green: #2F7D5A;
  --green-bg: #E7F3ED;
  --amber: #B5790F;
  --amber-bg: #FBF0DD;
  --red: #C4402E;
  --red-bg: #FBEAE7;
  --blue: #2A5F8A;
  --blue-bg: #E8F0F7;
  --neutral-bg: #ECEAE3;

  --radius: 10px;
  --radius-sm: 6px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 0.5em 0; font-weight: 700; color: var(--navy); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 1em 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--neutral-bg); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }

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

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.offline-banner {
  background: var(--amber-bg);
  color: var(--amber);
  text-align: center;
  padding: 8px 12px;
  padding-top: calc(8px + var(--safe-top));
  font-weight: 600;
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  padding-top: calc(14px + var(--safe-top));
  background: var(--navy);
  color: white;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.2px;
}

.desktop-nav {
  display: none;
  gap: 4px;
  flex: 1;
}

.topbar-user {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
}

.view-outlet {
  flex: 1;
  padding: 20px 16px 90px 16px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
}

.mobile-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 10;
}

.mobile-nav-link {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
}
.mobile-nav-link.active { color: var(--orange); }
.mobile-nav-link:hover { text-decoration: none; }

@media (min-width: 880px) {
  .desktop-nav { display: flex; }
  .mobile-nav { display: none; }
  .view-outlet { padding-bottom: 40px; }

  .nav-link {
    color: rgba(255,255,255,0.75);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.92rem;
  }
  .nav-link:hover { color: white; text-decoration: none; background: rgba(255,255,255,0.08); }
  .nav-link.active { color: white; background: rgba(255,255,255,0.16); }
}

/* ---------- Page structure ---------- */

.page { padding-top: 4px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meta-id {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 2px;
}

.section { margin-top: 28px; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.link { font-size: 0.9rem; font-weight: 600; }

.muted { color: var(--ink-soft); }

.notice {
  background: var(--blue-bg);
  color: var(--navy);
  border: 1px solid #C7DAEA;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.92rem;
}

.empty-state, .empty-state-inline {
  color: var(--ink-soft);
  padding: 16px 0;
}
.empty-state-inline { padding: 8px 0; font-size: 0.9rem; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--orange); color: white; }
.btn-primary:hover { background: var(--orange-dark); }

.btn-secondary { background: var(--surface); color: var(--navy); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--neutral-bg); }

.btn-block { width: 100%; }
.btn-small { min-height: 38px; padding: 8px 14px; font-size: 0.88rem; }

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 16px; max-width: 560px; }

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.form input, .form select, .form textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 44px;
}
.form textarea { min-height: unset; resize: vertical; }

.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 560px) {
  .form-row { grid-template-columns: 1fr 1fr; }
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.inline-form input, .inline-form select {
  flex: 1;
  min-width: 120px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  min-height: 40px;
}
.inline-form-compact { margin-top: 8px; margin-bottom: 18px; }

/* ---------- Lists ---------- */

.list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  border-left: 4px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}
.list-row:hover { background: var(--neutral-bg); text-decoration: none; }

.list-row-title { font-weight: 600; }
.list-row-sub { font-size: 0.85rem; color: var(--ink-soft); margin-top: 2px; }

.status-neutral  { border-left-color: var(--ink-soft); }
.status-info     { border-left-color: var(--blue); }
.status-progress { border-left-color: var(--orange); }
.status-warn     { border-left-color: var(--amber); }
.status-success  { border-left-color: var(--green); }

/* ---------- Badges ---------- */

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-neutral  { background: var(--neutral-bg); color: var(--ink-soft); }
.badge-info     { background: var(--blue-bg);   color: var(--blue); }
.badge-progress { background: #FBE7DC;          color: var(--orange-dark); }
.badge-warn     { background: var(--amber-bg);  color: var(--amber); }
.badge-success  { background: var(--green-bg);  color: var(--green); }

/* ---------- Stat cards (dashboard) ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
@media (min-width: 560px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-label { font-size: 0.82rem; color: var(--ink-soft); margin-top: 6px; }
.stat-card-muted { background: var(--neutral-bg); }
.stat-card-muted .stat-value { color: var(--ink-soft); }
.stat-note { font-size: 0.72rem; color: var(--ink-soft); margin-top: 4px; font-style: italic; }

.glance-list { margin: 0; padding-left: 20px; color: var(--ink-soft); }
.glance-list li { margin-bottom: 4px; }

/* ---------- Detail grid ---------- */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
@media (min-width: 560px) {
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
.detail-label { font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 2px; }

/* ---------- Work scope ---------- */

.category-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface);
}
.category-title { font-weight: 700; color: var(--navy); margin-bottom: 8px; }

.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.item-row:first-child { border-top: none; }
.item-row-title { font-weight: 600; font-size: 0.94rem; }
.item-row-sub { font-size: 0.8rem; color: var(--ink-soft); }
.status-select {
  font-size: 0.82rem;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 36px;
}

/* ---------- Onboarding ---------- */

.onboarding {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--navy);
}
.onboarding-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 380px;
  width: 100%;
}
.onboarding-card h1 { font-size: 1.3rem; }
.onboarding-card p { color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- Accessibility ---------- */

:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

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