:root {
  color-scheme: dark;
  --bg: #07080a;
  --surface: #101217;
  --surface-2: #171a21;
  --text: #f6f7f9;
  --muted: #9aa1ad;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #e30613;
  --sympla: #1677ff;
  --ok: #27d17f;
  --warn: #ffb23f;
  --danger: #ff4f5d;
  --shadow: rgba(0, 0, 0, 0.34);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #151820;
  --muted: #5d6470;
  --line: rgba(12, 18, 28, 0.14);
  --shadow: rgba(14, 18, 28, 0.1);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(227, 6, 19, 0.18), transparent 28rem),
    radial-gradient(circle at 90% 6%, rgba(22, 119, 255, 0.14), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 6px;
  color: var(--warn);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.gideao-link {
  position: fixed;
  z-index: 20;
  left: 14px;
  top: 14px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 34px var(--shadow);
}
.gideao-link img { width: 30px; height: 30px; object-fit: contain; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}
.login-panel {
  width: min(100%, 440px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(16, 18, 23, 0.96), rgba(10, 11, 14, 0.92));
  padding: 30px;
  box-shadow: 0 28px 80px var(--shadow);
  text-align: center;
}
[data-theme="light"] .login-panel { background: var(--surface); }
.login-logo { width: min(250px, 72vw); margin-bottom: 18px; }
.login-panel h1 { margin: 0 0 8px; font-size: clamp(2rem, 8vw, 3.1rem); line-height: 0.95; text-transform: uppercase; }
.login-message { min-height: 22px; color: var(--danger); }

.app { min-height: 100vh; }
.topbar {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px 0 74px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 8, 10, 0.82);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
[data-theme="light"] .topbar { background: rgba(255, 255, 255, 0.86); }
.brand, .top-actions, .section-head, .record-header, .record-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand img { width: 38px; height: 38px; object-fit: contain; }
.brand strong { display: block; text-transform: uppercase; }
.brand span { display: block; color: var(--muted); font-size: 0.84rem; }
.operator-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: min(36vw, 420px);
  border: 1px solid rgba(80, 240, 176, 0.28);
  border-radius: 8px;
  background: rgba(80, 240, 176, 0.1);
  color: var(--ok);
  padding: 0 10px;
  font-size: 0.8rem;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.operator-badge.missing {
  border-color: rgba(255, 178, 63, 0.34);
  background: rgba(255, 178, 63, 0.12);
  color: var(--warn);
}

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 70px);
}
.rail {
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  background: rgba(16, 18, 23, 0.55);
}
.event-switcher {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.event-switcher label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}
.nav-item {
  width: 100%;
  min-height: 44px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 12px;
  font-weight: 800;
}
.nav-item.active, .nav-item:hover {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.content { padding: 18px; min-width: 0; }
.view { display: none; }
.view.active { display: block; }
.event-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(227, 6, 19, 0.11), transparent),
    var(--surface);
  padding: 14px;
  box-shadow: 0 14px 34px var(--shadow);
}
.event-banner.realized {
  background:
    linear-gradient(135deg, rgba(80, 240, 176, 0.12), transparent),
    var(--surface);
}
.event-banner h2 { margin: 0 0 4px; text-transform: uppercase; }
.event-banner p { margin: 0; color: var(--muted); }
.event-banner .banner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.event-banner a {
  color: var(--text);
  text-decoration: none;
}
.split {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 16px;
}
.search-panel, .record-panel, .panel, .record-card, .items-card, .responsible-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 34px var(--shadow);
}
.search-panel, .panel { padding: 16px; }
.record-panel { min-height: calc(100vh - 106px); padding: 16px; }
.section-head { justify-content: space-between; margin-bottom: 14px; }
.section-head h2, .section-head h3 { margin: 0; }
.search-box { display: flex; gap: 8px; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  padding: 12px;
}
input:focus, textarea:focus { border-color: var(--sympla); box-shadow: 0 0 0 4px rgba(22, 119, 255, 0.14); }

.results-list { display: grid; gap: 8px; margin-top: 14px; }
.result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
  text-align: left;
}
.result:hover, .result.active { border-color: var(--sympla); }
.result strong { display: block; }
.result span { display: block; color: var(--muted); font-size: 0.84rem; margin-top: 4px; }

.empty-state { min-height: 60vh; display: grid; place-content: center; text-align: center; color: var(--muted); }
.record-card { padding: 16px; }
.record-header { justify-content: space-between; align-items: flex-start; }
.record-header h2 { margin: 6px 0; font-size: clamp(1.45rem, 3vw, 2.1rem); }
.status-pill, .badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}
.status-pill.delivered { color: var(--ok); }
.status-pill.pending { color: var(--warn); }
.badge.subtle { color: var(--muted); }

.info-grid, .metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.info-grid div, .metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}
.info-grid span, .metric span { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; }
.info-grid strong, .metric strong { display: block; margin-top: 5px; font-size: 1.2rem; }

.items-card, .responsible-card { padding: 14px; margin-top: 14px; box-shadow: none; }
.items-list { display: grid; gap: 8px; }
.item-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}
.item-row input { width: 20px; height: 20px; }
.item-row strong { display: block; }
.item-row span { color: var(--muted); font-size: 0.82rem; }
.critical { color: var(--warn); font-weight: 900; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
label { display: grid; gap: 6px; color: var(--muted); font-size: 0.82rem; font-weight: 800; }
canvas {
  width: 100%;
  height: 210px;
  margin-top: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}
.notes-label { margin-top: 12px; }
.record-actions { justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

.primary-btn, .secondary-btn, .danger-btn, .icon-btn {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 900;
  padding: 0 14px;
}
.primary-btn { border-color: rgba(227, 6, 19, 0.7); background: linear-gradient(135deg, var(--accent), #8f0009); }
.sympla-btn { min-height: 42px; border-radius: 8px; border: 1px solid rgba(22, 119, 255, 0.7); background: linear-gradient(135deg, var(--sympla), #005fbd); color: #fff; font-weight: 900; padding: 0 14px; }
.secondary-btn, .icon-btn { background: var(--surface-2); }
.danger-btn { background: rgba(255, 79, 93, 0.12); color: var(--danger); }
.compact { min-height: 34px; padding: 0 10px; font-size: 0.84rem; }
.icon-btn { min-width: 42px; padding: 0; }

.status-bars, .table-like, .audit-list { display: grid; gap: 8px; }
.bar-row, .table-row, .audit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}
.bar-track { height: 9px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.08); margin-top: 8px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--sympla), var(--ok)); }

#csvFile { margin: 12px 0; }
#csvText { margin-bottom: 12px; }
.import-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.import-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
}
.import-card h3 { margin: 0 0 6px; }
.import-card input { margin: 10px 0; }
.import-card textarea { margin-bottom: 10px; }
.import-preview {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
}
.preview-card h3 { margin: 0 0 12px; }
.preview-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.preview-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}
.preview-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}
.preview-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
}
.preview-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  max-height: 260px;
  overflow: auto;
}
.preview-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface);
}
.preview-row .ok { color: var(--ok); }
.preview-row .warn { color: var(--warn); }
.preview-row .danger { color: var(--danger); }
.staff-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  gap: 14px;
  margin-top: 16px;
}
.staff-form,
.staff-list-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
}
.staff-form h3,
.staff-list-card h3 {
  margin: 0 0 12px;
}
.staff-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}
.staff-row strong,
.staff-row span {
  display: block;
}
.staff-row span {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}
.staff-row.active {
  border-color: rgba(80, 240, 176, 0.42);
  box-shadow: inset 0 0 0 1px rgba(80, 240, 176, 0.18);
}

@media (max-width: 980px) {
  .workspace, .split { grid-template-columns: 1fr; }
  .rail { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-item { min-width: 140px; }
  .topbar { padding-left: 66px; }
  .info-grid, .metric-grid, .form-grid { grid-template-columns: 1fr 1fr; }
  .import-grid, .event-banner { grid-template-columns: 1fr; }
  .staff-layout { grid-template-columns: 1fr; }
  .preview-metrics { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; height: auto; padding-block: 12px; flex-direction: column; }
  .top-actions { width: 100%; justify-content: flex-end; }
  .operator-badge { max-width: 100%; width: 100%; justify-content: center; }
  .info-grid, .metric-grid, .form-grid { grid-template-columns: 1fr; }
  .preview-metrics, .preview-row { grid-template-columns: 1fr; }
}
