:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #5e6ad2;
  --accent-hover: #4f58b8;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --status-problem: #fecaca;
  --status-problem-text: #991b1b;
  --status-work: #fef08a;
  --status-work-text: #854d0e;
  --status-ok: #bbf7d0;
  --status-ok-text: #166534;
}

[data-theme="dark"] {
  --bg: #0d0d0f;
  --surface: #161618;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --border: #27272a;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --status-problem: rgba(220, 38, 38, 0.35);
  --status-problem-text: #fecaca;
  --status-work: rgba(234, 179, 8, 0.35);
  --status-work-text: #fef9c3;
  --status-ok: rgba(22, 163, 74, 0.35);
  --status-ok-text: #bbf7d0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.view {
  min-height: 100vh;
}

#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
}

.login-title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 600;
  letter-spacing: -0.03em;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
}

.tab:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--border) 50%, transparent);
}

.tab.active {
  color: var(--text);
  background: var(--border);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  width: 220px;
  max-width: 40vw;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
}

.main {
  padding: 16px 20px 48px;
  max-width: 1400px;
  margin: 0 auto;
}

.sticky-filters {
  position: sticky;
  top: 56px;
  z-index: 30;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

.field.compact input,
.field.compact select {
  padding: 6px 8px;
  font-size: 0.8125rem;
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field textarea {
  resize: vertical;
  min-height: 72px;
}

.btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: color-mix(in srgb, var(--border) 60%, transparent);
}

.btn-block {
  width: 100%;
  margin-top: 8px;
}

.btn.icon {
  font-size: 1.25rem;
  line-height: 1;
  padding: 4px 10px;
}

.error {
  color: var(--danger);
  font-size: 0.8125rem;
  margin: 0;
}

.table-wrap {
  overflow: hidden;
}

.table-toolbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table thead th {
  font-weight: 500;
  color: var(--muted);
  background: color-mix(in srgb, var(--bg) 40%, var(--surface));
  position: sticky;
  top: 0;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.data-table tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.data-table.compact th,
.data-table.compact td {
  padding: 8px 10px;
}

.cell-input,
.cell-select {
  width: 100%;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
}

.cell-input:focus,
.cell-select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.desc-preview {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-problem {
  background: var(--status-problem);
  color: var(--status-problem-text);
}

.badge-work {
  background: var(--status-work);
  color: var(--status-work-text);
}

.badge-resolved {
  background: var(--status-ok);
  color: var(--status-ok-text);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  padding: 16px;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-title {
  padding: 16px;
  margin-bottom: 16px;
}

.section-title h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.chart-card {
  padding: 16px;
}

.chart-card h3 {
  margin: 0 0 12px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
}

.chart-card canvas {
  max-height: 280px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  padding: 0;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

#claim-form {
  padding: 16px 20px 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .field.full {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 90;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100%;
  z-index: 95;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  pointer-events: none;
}

.drawer.open {
  transform: translateX(0);
  pointer-events: auto;
}

.drawer-inner {
  height: 100%;
  border-radius: 0;
  border-right: none;
  border-top: none;
  border-bottom: none;
  overflow: auto;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.drawer-body {
  padding: 16px;
  font-size: 0.875rem;
}

.drawer-body dl {
  margin: 0;
}

.drawer-body dt {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 12px;
}

.drawer-body dd {
  margin: 4px 0 0;
}

.panel.hidden {
  display: none;
}
