:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e2e6ee;
  --text: #1a1f2b;
  --text-dim: #6b7280;
  --accent: #005aff;
  --accent-dim: #3d8bff;
  --sidebar-bg: #10131d;
  --sidebar-text: #aab1c5;
  --sidebar-text-active: #ffffff;
  --danger: #e5484d;
  --danger-bg: #fde7e8;
  --warn: #b45309;
  --warn-bg: #fdf3d8;
  --ok: #16794f;
  --ok-bg: #dcf6e9;
  --info: #1d4ed8;
  --info-bg: #e1eaff;
  --neutral-bg: #eceef3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 19, 29, 0.06), 0 8px 24px rgba(16, 19, 29, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.sidebar__brand {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  letter-spacing: 0.02em;
  padding: 0 10px 22px;
}

.sidebar__brand span { color: var(--accent-dim); }

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__link {
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s, color 0.15s;
}

.sidebar__link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar__link.active { background: var(--accent); color: #fff; }

.sidebar__online {
  margin-top: 16px;
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar__online-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sidebar-text);
  font-weight: 700;
  margin-bottom: 8px;
}

.sidebar__online-user {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: #fff;
  padding: 3px 0;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.18);
  flex-shrink: 0;
}

.sidebar__footer {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12.5px;
}

.sidebar__user { color: #fff; font-weight: 600; margin-bottom: 2px; }
.sidebar__role { color: var(--sidebar-text); margin-bottom: 10px; }
.sidebar__logout { color: var(--sidebar-text); }
.sidebar__logout:hover { color: #fff; }

/* Main */
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 34px 60px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 21px;
  margin: 0 0 4px;
}

.page-head__sub {
  color: var(--text-dim);
  font-size: 13px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

input[type="text"], input[type="date"], input[type="number"], select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(61,139,255,0.15);
}

.search-input { width: 240px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #0048d1; }

.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #f9d2d3; }

.btn-sm { padding: 5px 9px; font-size: 12.5px; }

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

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

table { width: 100%; border-collapse: collapse; min-width: 720px; }

thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-neutral { background: var(--neutral-bg); color: var(--text-dim); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-info { background: var(--info-bg); color: var(--info); }

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  background: var(--neutral-bg);
  color: var(--text-dim);
}

.badge-count.is-high { background: var(--danger-bg); color: var(--danger); }
.badge-count.is-points { background: var(--info-bg); color: var(--info); font-weight: 700; }

.warn-cell { display: flex; align-items: center; gap: 5px; }

.warn-btn {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.warn-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.warn-btn-plus:not(:disabled):hover { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.warn-btn-minus:not(:disabled):hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.row-actions { display: flex; gap: 6px; white-space: nowrap; }

.muted { color: var(--text-dim); }

.empty-state {
  padding: 46px 20px;
  text-align: center;
  color: var(--text-dim);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16,19,29,0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 60px rgba(16,19,29,0.25);
}

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

.modal__head h2 { font-size: 16px; margin: 0; }

.modal__close {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  background: none;
  border: none;
}

.modal__body {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

.modal__body .full { grid-column: 1 / -1; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.field input, .field select, .field textarea { width: 100%; }
.field textarea { resize: vertical; min-height: 56px; }

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.criteria-card {
  margin-bottom: 16px;
  padding: 0;
}

.criteria-card summary {
  cursor: pointer;
  padding: 13px 18px;
  font-weight: 600;
  font-size: 13.5px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.criteria-card summary::before {
  content: "▸";
  color: var(--text-dim);
  transition: transform 0.15s;
}

.criteria-card[open] summary::before {
  transform: rotate(90deg);
}

.criteria-card summary::-webkit-details-marker { display: none; }

.criteria-body {
  padding: 4px 18px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.criteria-block { padding-top: 14px; }

.criteria-note { margin: 0; font-size: 12.5px; }

.report-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.report-card { padding: 0; }

.report-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}

.report-card__body { padding: 16px 18px; }

.report-card__body p {
  margin: 4px 0 12px;
  white-space: pre-line;
  line-height: 1.5;
}

.report-card__label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 2px;
}

.report-points {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.report-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.report-gallery__item {
  position: relative;
  width: 120px;
  height: 90px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.report-gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.report-gallery__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(16,19,29,0.65);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.report-gallery__remove:hover { background: var(--danger); }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #10131d 0%, #171b2a 100%);
}

.login-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 34px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.35);
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
}

.login-card p.muted { margin: 0 0 22px; font-size: 13px; }

.login-card .field { margin-bottom: 14px; }

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--neutral-bg);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; align-items: center; }
  .sidebar__brand { display: none; }
  .sidebar__nav { flex-direction: row; }
  .sidebar__footer { display: none; }
  .sidebar__online { display: none; }
  .main { padding: 18px; }
  .modal__body { grid-template-columns: 1fr; }
}
