:root {
  --border: #dcdcdc;
  --text: #000000;
  --muted: #5c5c5c;
  --accent: #ff6c1f;
  --accent-tint: #ffe9dd;
  --dark: #000000;
  --on-dark: #ffffff;
  --on-dark-muted: #c8c8c8;
  --bg: #f5f5f5;
  --font: 'Exo 2', -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  margin: 0;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

@media (max-width: 640px), (max-height: 500px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .container { padding: 1.25rem 1rem; }
}

header.site {
  background: var(--dark);
  color: var(--accent);
  padding: 1rem 1.25rem;
  border-bottom: 4px solid var(--accent);
}

.wordmark-lead { color: var(--accent); }
.wordmark-rest { color: var(--on-dark); }

header.site h1,
header.site .brand-link {
  display: block;
  margin: 0;
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 800;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; }

a { color: var(--text); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }

form .field { margin-bottom: 1rem; }

.form-grid { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-start; }
.form-grid .field { flex: 1 1 220px; min-width: 0; }
.form-grid .field:has(textarea) { flex-basis: 100%; }
.form-grid .field:has([data-address-autocomplete]) { flex-basis: 100%; }
.form-grid h4 { flex-basis: 100%; margin: 0.75rem 0 0.15rem; }
.form-grid h4:first-child { margin-top: 0; }
.form-grid > button, .form-grid > .btn { flex: 0 0 auto; margin-top: 0.25rem; }

.address-suggestions {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}
.address-suggestion { padding: 0.5rem 0.6rem; cursor: pointer; font-size: 0.9rem; }
.address-suggestion:hover { background: var(--bg); }

label { display: block; font-weight: 600; margin-bottom: 0.25rem; }

input, textarea, select {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}

textarea { min-height: 6rem; }

button, .btn {
  display: inline-block;
  background: var(--accent);
  color: var(--dark);
  font-weight: 600;
  font-family: inherit;
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
}

button:hover, .btn:hover { opacity: 0.9; color: var(--dark); }

.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { opacity: 1; border-color: var(--dark); }
.btn-danger, .btn-danger:hover { background: #b3261e; color: white; }

.link-danger {
  background: none;
  border: none;
  padding: 0;
  color: #b3261e;
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
}
.link-danger:hover { opacity: 0.8; }

dialog.confirm-dialog {
  border: none;
  border-radius: 8px;
  padding: 1.25rem;
  width: 90vw;
  max-width: 420px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}
dialog.confirm-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog.confirm-dialog p { margin-top: 0; }
.dialog-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}
.dialog-actions form { margin: 0; }
.dialog-actions button { flex: 0 0 auto; white-space: nowrap; margin: 0; }

table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; }

.table-responsive td, .table-responsive th { word-break: break-word; }

@media (max-width: 700px), (max-height: 500px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .table-responsive table, .table-responsive tbody, .table-responsive tr, .table-responsive td {
    display: block;
    width: 100%;
  }
  .table-responsive thead { display: none; }
  .table-responsive tr {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.75rem;
  }
  .table-responsive td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.3rem 0;
    border-bottom: none;
  }
  .table-responsive td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--muted);
  }
}

nav.admin {
  background: var(--dark);
  border-bottom: 4px solid var(--accent);
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.25rem;
}
nav.admin a { color: var(--on-dark); text-decoration: none; font-weight: 500; }
nav.admin a:hover { color: var(--accent); }
nav.admin a.brand {
  font-weight: 800;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--accent);
}
nav.admin a.logout { margin-left: auto; }

.nav-links { display: contents; }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--muted);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--on-dark);
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

@media (max-width: 700px), (max-height: 500px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .nav-toggle { display: inline-block; }

  .nav-links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-top: 0.25rem;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 0.65rem 0.1rem; border-top: 1px solid #333333; }
  nav.admin .nav-links a.logout { margin-left: 0; }

  .flex-between { flex-wrap: wrap; gap: 0.5rem; }

  button, .btn, .range-btn { padding: 0.75rem 1.1rem; }
  input, textarea, select { padding: 0.7rem 0.65rem; }

  .form-grid > button, .form-grid > .btn { flex-basis: 100%; width: 100%; margin-top: 0.75rem; }
}

.card { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; margin-bottom: 1rem; }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.8rem; background: var(--accent-tint); color: var(--text); }
.muted { color: var(--muted); }

.error { color: #b3261e; margin-bottom: 1rem; }
.success { color: #1e7a34; }

.flex-between { display: flex; justify-content: space-between; align-items: center; }

.range-toggle { display: flex; gap: 0.5rem; margin: 0.75rem 0; flex-wrap: wrap; }
.range-btn {
  background: white;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
}
.range-btn.active { background: var(--accent); color: var(--dark); border-color: var(--accent); }
.range-btn:hover:not(.active) { background: var(--bg); }
a.range-btn { text-decoration: none; }
a.range-btn:hover { color: var(--text); }
.inline-filter { margin: 0; }
.inline-filter select { width: auto; padding: 0.35rem 0.6rem; border-radius: 999px; font-size: 0.85rem; }

.badge-low { background: var(--accent); color: var(--dark); font-weight: 600; }

.qty-adjust { display: inline-flex; align-items: center; gap: 0.5rem; }
.qty-adjust form { margin: 0; }
.qty-btn {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
}
.qty-btn:hover { opacity: 1; border-color: var(--accent); }
.qty-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.qty-value { min-width: 1.75rem; text-align: center; font-weight: 600; }

.summary-totals { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; font-size: 0.95rem; }

.chart-legend { display: flex; gap: 1.25rem; margin-bottom: 0.5rem; font-size: 0.85rem; color: var(--muted); }
.chart-legend-item { display: flex; align-items: center; gap: 0.4rem; }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.chart-svg-wrap { position: relative; }
.chart-svg-wrap svg { display: block; width: 100%; height: auto; }

.chart-tooltip {
  position: absolute;
  z-index: 5;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  min-width: 140px;
}
.chart-tooltip-title { color: var(--muted); font-size: 0.75rem; margin-bottom: 0.3rem; text-transform: uppercase; }
.chart-tooltip-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.1rem 0; }
.chart-tooltip-key { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: 0 0 auto; }
.chart-tooltip-name { color: var(--muted); margin-left: auto; }

.hero { background: var(--dark); color: var(--on-dark); }
.hero h1 { margin-top: 0; margin-bottom: 0.83em; font-size: 2rem; }
body.portal .container > h3 { margin-top: 2.25rem; margin-bottom: 0.75rem; }
body.portal .container > h3:first-child { margin-top: 0; }
body.portal .container > p.muted { margin-top: 0; }
body.portal .container > h1 { margin-top: 0; font-size: 1.5rem; }
body.portal .hero .container > h1 { font-size: 2rem; margin-bottom: 0.83em; }
.hero .crumbs { margin: 0 0 0.75rem; font-size: 0.85rem; color: var(--on-dark-muted); }
.hero .crumbs a { color: var(--on-dark-muted); }
.prose { max-width: 820px; margin-left: 0; }
.services-grid h4 a { text-decoration: none; }

details.faq { border-bottom: 1px solid var(--border); padding: 0.75rem 0; }
details.faq summary { cursor: pointer; font-weight: 600; }
details.faq p { margin: 0.5rem 0 0; }

.site-footer { background: var(--dark); color: var(--on-dark-muted); margin-top: 2rem; border-top: 4px solid var(--accent); }
.site-footer h4 { color: var(--on-dark); margin: 0 0 0.5rem; }
.site-footer a { color: var(--on-dark-muted); }
.site-footer a:hover { color: var(--accent); }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 0.3rem; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; }
.hero .lead { font-size: 1.1rem; color: var(--on-dark-muted); max-width: 640px; }

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.services-grid h4 { margin-top: 0; margin-bottom: 0.4rem; }

.small { font-size: 0.85rem; }
code { font-size: 0.85em; background: var(--bg); padding: 0.05rem 0.3rem; border-radius: 4px; word-break: break-all; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.stat-tile { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.1rem; }
.stat-label { color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin: 0.25rem 0; }
.stat-note { color: var(--muted); font-size: 0.8rem; }

.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 1rem; }

.hbar-row { margin: 0.7rem 0; }
.hbar-head { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.9rem; margin-bottom: 0.3rem; }
.hbar-head strong { font-weight: 600; white-space: nowrap; }
.hbar-track { background: var(--bg); border-radius: 4px; height: 10px; overflow: hidden; }
.hbar-fill { background: #e8590c; height: 100%; border-radius: 4px; min-width: 2px; }

table.compact { margin: 0.5rem 0; }
table.compact th, table.compact td { padding: 0.4rem 0.5rem; }

.badge.status-good, .badge.status-warn, .badge.status-bad { white-space: nowrap; }
.status-good { background: #e3f4e8; color: #1e6b34; }
.status-warn { background: #fff4d6; color: #7a5a00; }
.status-bad { background: #fde4e2; color: #9e231b; }
