:root {
  --bg: #101312;
  --surface: #171b19;
  --surface-2: #20251f;
  --surface-3: #262821;
  --line: #343a33;
  --text: #f3f0e8;
  --muted: #b9b4a8;
  --soft: #8d968a;
  --accent: #62d68a;
  --accent-dark: #15351f;
  --amber: #f2c14e;
  --danger: #ff6b5f;
  --info: #7fc7d9;
  --radius: 8px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100svh;
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Aptos", system-ui, sans-serif;
  background:
    linear-gradient(180deg, rgba(98, 214, 138, 0.08), transparent 19rem),
    linear-gradient(145deg, #101312 0%, #151814 52%, #1b1a14 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.app-frame {
  width: min(100%, 74rem);
  margin: 0 auto;
  padding: 0.75rem;
}

.login-screen {
  min-height: calc(100svh - 1.5rem);
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(100%, 25rem);
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 27, 25, 0.92);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.65rem;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0.2rem;
  font-size: 0.98rem;
  letter-spacing: 0;
}

.muted,
.brief-line,
small {
  color: var(--muted);
  line-height: 1.4;
}

label {
  display: grid;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.72rem 0.78rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1210;
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.42;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(98, 214, 138, 0.65);
  box-shadow: 0 0 0 3px rgba(98, 214, 138, 0.12);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0 0.65rem;
  background: linear-gradient(180deg, rgba(16, 19, 18, 0.96), rgba(16, 19, 18, 0.78));
  backdrop-filter: blur(16px);
}

.main-nav {
  display: flex;
  gap: 0.44rem;
  overflow-x: auto;
  padding: 0.25rem 0 0.7rem;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.nav-button,
.scope-button,
.secondary-button,
.primary-button,
.icon-button,
.danger-button {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.nav-button {
  flex: 0 0 auto;
  padding: 0 0.78rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
}

.dashboard-scope {
  display: flex;
  flex-wrap: wrap;
  gap: 0.44rem;
}

.scope-button {
  padding: 0 0.8rem;
  background: var(--surface);
  color: var(--muted);
}

.scope-button.is-active {
  border-color: rgba(98, 214, 138, 0.5);
  background: var(--accent-dark);
  color: #dfffe8;
}

.nav-button.is-active {
  border-color: rgba(98, 214, 138, 0.5);
  background: var(--accent-dark);
  color: #dfffe8;
}

.primary-button {
  padding: 0 1rem;
  border-color: rgba(98, 214, 138, 0.72);
  background: var(--accent);
  color: #071109;
}

.secondary-button,
.icon-button {
  padding: 0 0.9rem;
  background: var(--surface-2);
}

.danger-button {
  padding: 0 0.9rem;
  border-color: rgba(255, 107, 95, 0.52);
  background: rgba(255, 107, 95, 0.12);
  color: #ffd4d0;
}

.voice-panel {
  gap: 0.65rem;
}

.notification-panel {
  gap: 0.55rem;
}

.notification-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.notification-main small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  line-height: 1.35;
}

.notification-status {
  margin: 0.22rem 0 0;
  color: var(--amber);
  font-size: 0.9rem;
  font-weight: 800;
}

.notification-status[data-mode="active"] {
  color: var(--accent);
}

.notification-status[data-mode="blocked"],
.notification-status[data-mode="error"] {
  color: var(--danger);
}

.notification-actions {
  justify-content: flex-end;
}

.voice-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.voice-button {
  min-height: 3.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0 1rem;
  border: 1px solid rgba(98, 214, 138, 0.72);
  border-radius: var(--radius);
  background: var(--accent);
  color: #071109;
  cursor: pointer;
  font-weight: 900;
}

.voice-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.voice-icon {
  width: 1.18rem;
  height: 1.18rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.voice-status[data-mode="listening"] {
  color: var(--accent);
}

.voice-status[data-mode="processing"] {
  color: var(--info);
}

.voice-status[data-mode="ready"] {
  color: var(--accent);
}

.voice-status[data-mode="warning"] {
  color: var(--amber);
}

.voice-editor {
  display: grid;
  gap: 0.6rem;
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 0.75rem;
}

.content-band {
  display: grid;
  gap: 0.75rem;
  padding: 0.78rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 27, 25, 0.86);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.62rem;
}

.reminder-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.62rem;
}

.reminder-status-grid > div {
  display: grid;
  align-content: start;
  gap: 0.5rem;
}

.metric-card,
.item-card,
.route-card,
.info-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-card {
  min-height: 5.25rem;
  display: grid;
  align-content: space-between;
  gap: 0.55rem;
  padding: 0.72rem;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.metric-label,
.tile-label,
.item-meta {
  color: var(--soft);
  font-size: 0.72rem;
  line-height: 1.3;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1;
}

.item-list,
.route-list {
  display: grid;
  gap: 0.58rem;
}

.item-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.72rem;
}

.item-card.is-urgent {
  border-color: rgba(255, 107, 95, 0.52);
  background: linear-gradient(135deg, rgba(255, 107, 95, 0.14), var(--surface) 44%);
}

.clickable-card {
  cursor: pointer;
}

.clickable-card:focus,
.clickable-card:hover,
.metric-card:focus,
.metric-card:hover {
  border-color: rgba(98, 214, 138, 0.5);
  box-shadow: 0 0 0 3px rgba(98, 214, 138, 0.08);
}

.item-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.item-title {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.25;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.62rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.urgent {
  border-color: rgba(255, 107, 95, 0.55);
  background: rgba(255, 107, 95, 0.12);
  color: #ffd4d0;
}

.badge.high {
  border-color: rgba(242, 193, 78, 0.5);
  background: rgba(242, 193, 78, 0.12);
  color: #ffe7a6;
}

.badge.ok {
  border-color: rgba(98, 214, 138, 0.5);
  background: rgba(98, 214, 138, 0.12);
  color: #dfffe8;
}

.item-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.48rem;
}

.item-actions button {
  min-height: 2.25rem;
  padding: 0 0.68rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
}

.item-actions .danger-button,
.item-card-head .danger-button {
  border-color: rgba(255, 107, 95, 0.52);
  background: rgba(255, 107, 95, 0.12);
  color: #ffd4d0;
}

.inline-actions {
  align-items: center;
  justify-content: flex-end;
}

.parse-card-list {
  display: grid;
  gap: 0.75rem;
}

.parse-card {
  display: grid;
  gap: 0.7rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.parse-card-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.parse-fields {
  align-items: end;
}

.suggestion-line {
  margin: 0;
  color: var(--amber);
  font-size: 0.82rem;
}

.advanced-json-panel {
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}

.advanced-json-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.detail-panel {
  position: sticky;
  top: 4.6rem;
  z-index: 9;
  box-shadow: var(--shadow);
}

.item-detail-form,
.customer-edit-form {
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

.pool-card {
  gap: 0.72rem;
}

.pool-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.pool-status-grid p {
  margin: 0.24rem 0 0;
}

.pool-open-jobs {
  display: grid;
  gap: 0.45rem;
}

.pool-job-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.52rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.25;
}

.route-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.72rem;
  padding: 0.72rem;
}

.route-actions {
  margin-top: 0.48rem;
}

.route-rank {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #071109;
  font-weight: 900;
}

.stack-form,
.compact-form {
  display: grid;
  gap: 0.6rem;
}

.json-editor {
  min-height: 24rem;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.82rem;
}

.parser-mode-label {
  margin: 0.28rem 0 0;
  color: var(--amber);
  font-size: 0.74rem;
  font-weight: 800;
}

.parser-mode-label.is-openai {
  color: var(--accent);
}

.form-message {
  padding: 0.72rem;
  border: 1px solid rgba(242, 193, 78, 0.36);
  border-radius: var(--radius);
  background: rgba(242, 193, 78, 0.12);
  color: #ffe7a6;
  line-height: 1.38;
}

.form-message.is-error {
  border-color: rgba(255, 107, 95, 0.45);
  background: rgba(255, 107, 95, 0.12);
  color: #ffd4d0;
}

.settings-grid {
  display: grid;
  gap: 0.62rem;
}

.info-tile {
  display: grid;
  gap: 0.38rem;
  padding: 0.72rem;
}

code {
  padding: 0.08rem 0.24rem;
  border-radius: 4px;
  background: #0f1210;
  color: var(--accent);
}

.empty-state {
  margin: 0;
  padding: 0.88rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

@media (min-width: 48rem) {
  .app-frame {
    padding: 1rem;
  }

  h1 {
    font-size: 2.2rem;
  }

  .summary-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .two-column,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-form {
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    align-items: end;
  }

  #history-filter {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 42rem) {
  html {
    font-size: 15px;
  }

  .app-frame {
    padding: 0.5rem;
  }

  .topbar {
    gap: 0.55rem;
    padding: 0.55rem 0 0.45rem;
  }

  .main-nav {
    gap: 0.34rem;
    padding-bottom: 0.48rem;
  }

  .nav-button,
  .secondary-button,
  .primary-button,
  .icon-button {
    min-height: 2.35rem;
    padding-inline: 0.62rem;
    font-size: 0.78rem;
  }

  h1 {
    font-size: 1.42rem;
  }

  h2 {
    font-size: 0.94rem;
  }

  .view.is-active,
  .content-band,
  .item-list,
  .route-list,
  .reminder-status-grid {
    gap: 0.48rem;
  }

  .content-band,
  .item-card,
  .route-card,
  .metric-card {
    padding: 0.58rem;
  }

  .metric-card {
    min-height: 4.2rem;
  }

  .metric-value {
    font-size: 1.35rem;
  }

  .item-title {
    font-size: 0.9rem;
  }

  .item-meta {
    gap: 0.22rem 0.45rem;
    font-size: 0.68rem;
  }

  .badge {
    min-height: 1.32rem;
    padding-inline: 0.4rem;
    font-size: 0.62rem;
  }

  .reminder-status-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .voice-main {
    display: grid;
    gap: 0.4rem;
  }

  .notification-main {
    display: grid;
  }

  .notification-actions {
    justify-content: start;
  }

  .voice-button {
    width: 100%;
    min-height: 2.65rem;
  }

  .voice-status {
    text-align: left;
  }
}

@media (max-width: 25rem) {
  .app-frame {
    padding: 0.42rem;
  }

  .topbar {
    align-items: flex-start;
  }

  .item-card-head {
    display: grid;
  }

  .pool-status-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
