:root {
  --bg: #0d1117;
  --bg-grid: #131822;
  --panel: #161b22;
  --panel-border: #232a35;
  --panel-border-soft: #1c222c;
  --text: #e6edf3;
  --text-muted: #7d8590;
  --text-faint: #4b5563;

  --accent: #4fb8c9;
  --accent-soft: rgba(79, 184, 201, 0.12);

  --day: #3ecf8e;
  --day-soft: rgba(62, 207, 142, 0.14);
  --night: #7c83fd;
  --night-soft: rgba(124, 131, 253, 0.16);

  --danger: #f0a860;

  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-sans: 'IBM Plex Sans', system-ui, sans-serif;

  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px) 0 0 / 28px 100%,
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.hidden { display: none !important; }

/* ---------- Login screen ---------- */

.login {
  width: 100%;
  max-width: 360px;
  display: flex;
  justify-content: center;
}

.login__panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login__title {
  margin: 0 0 18px;
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
}

.text-input {
  appearance: none;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  margin: 6px 0 16px;
  transition: border-color 0.15s ease;
}

.text-input::placeholder { color: var(--text-faint); }

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

.login .submit {
  margin-top: 4px;
}

/* ---------- Console shared ---------- */

.console {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.console__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand__eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 6px;
}

.brand__title {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.brand__user {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.readout {
  text-align: right;
  font-family: var(--font-mono);
}

.readout__row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.readout__clock {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.readout__date {
  font-size: 12px;
  color: var(--text-muted);
}

.readout__row--shift {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.readout__divider { color: var(--text-faint); }

.shift-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--day);
  box-shadow: 0 0 0 3px var(--day-soft);
  animation: pulse 2.4s ease-in-out infinite;
}

.shift-dot.is-night {
  background: var(--night);
  box-shadow: 0 0 0 3px var(--night-soft);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---------- Panel ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field__label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field__hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

/* Segmented control */

.segmented {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 3px;
  width: fit-content;
}

.segmented__option {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented__option:hover { color: var(--text); }

.segmented__option.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.segmented__option:focus-visible,
.chip:focus-visible,
.submit:focus-visible,
.text-input:focus-visible,
.mini-add:focus-visible,
.mini-remove:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Chips */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Filename preview */

.preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px dashed var(--panel-border);
  border-radius: 8px;
}

.preview__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.preview__filename {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  word-break: break-all;
  transition: color 0.2s ease;
}

.preview__filename.is-ready { color: var(--accent); }

/* Submit */

.submit {
  appearance: none;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #06181c;
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 600;
  padding: 13px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.15s ease, transform 0.05s ease;
}

.submit:disabled {
  background: var(--panel-border);
  color: var(--text-faint);
  cursor: not-allowed;
}

.submit:not(:disabled):hover { opacity: 0.92; }
.submit:not(:disabled):active { transform: scale(0.99); }

.submit__spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(6, 24, 28, 0.35);
  border-top-color: #06181c;
  display: none;
}

.submit.is-loading .submit__spinner {
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

.submit.is-loading .submit__label { opacity: 0.85; }

@keyframes spin { to { transform: rotate(360deg); } }

.status-line {
  margin: 0;
  min-height: 16px;
  font-size: 12.5px;
  color: var(--danger);
}

.status-line.is-success { color: var(--day); }

/* ---------- Dynamic group cards (incident / load tables) ---------- */

.group-card {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

.group-card + .group-card { margin-top: 12px; }

.group-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.group-card__form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.mini-input {
  appearance: none;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12.5px;
  padding: 8px 10px;
}

.mini-input::placeholder { color: var(--text-faint); }

.mini-input:focus {
  outline: none;
  border-color: var(--accent);
}

.mini-add {
  appearance: none;
  border: 1px dashed var(--accent);
  background: transparent;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  width: fit-content;
  transition: background 0.15s ease;
}

.mini-add:hover { background: var(--accent-soft); }

.group-card__rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.group-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border-soft);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.group-card__row-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-remove {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.group-card__empty {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}

/* Footer */

.console__footer {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Reduced motion */

@media (prefers-reduced-motion: reduce) {
  .shift-dot { animation: none; }
  .submit__spinner { animation: none; }
}

/* Mobile */

@media (max-width: 420px) {
  .console__header { flex-direction: column; }
  .readout { text-align: left; }
  .readout__row,
  .readout__row--shift { justify-content: flex-start; }
  .panel { padding: 18px; }
}

