:root {
  color-scheme: light;
  --bg: #f3faf7;
  --surface: #ffffff;
  --surface-2: #e7f5ee;
  --text: #1d2430;
  --muted: #5f716c;
  --line: #cfe7dc;
  --accent: #0f766e;
  --accent-2: #16a34a;
  --accent-soft: #dcfce7;
  --accent-line: #86efac;
  --danger: #b42318;
  --warn: #b7791f;
  --ok: #15803d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(220, 252, 231, 0.7), rgba(243, 250, 247, 0.9) 220px),
    var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

button.secondary {
  background: var(--surface-2);
  color: #14532d;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 700;
}

.button-link.secondary {
  background: var(--surface-2);
  color: #14532d;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 10px;
  background: white;
  color: var(--text);
}

textarea {
  min-height: 180px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.14);
  outline: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input[type="checkbox"] {
  width: auto;
  min-height: 0;
  accent-color: var(--accent);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkbox-field.inline {
  justify-content: flex-start;
}

.shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid #b7dfcc;
  background: rgba(247, 253, 250, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: linear-gradient(135deg, #065f46, var(--accent-2));
}

.brand h1 {
  font-size: 18px;
  margin: 0;
}

.brand p, .muted {
  margin: 0;
  color: var(--muted);
}

.content {
  width: min(1440px, calc(100vw - 32px));
  margin: 28px auto 60px;
  display: grid;
  gap: 18px;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 16px;
  box-shadow: 0 18px 60px rgba(29, 36, 48, 0.08);
}

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

.grid {
  display: grid;
  gap: 16px;
}

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

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid rgba(22, 163, 74, 0.55);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.panel h2, .panel h3 {
  margin: 0;
}

.panel h2 {
  font-size: 20px;
}

.panel h3 {
  font-size: 16px;
}

.algorithm-panel {
  max-width: 980px;
}

.algorithm-panel p,
.algorithm-panel ul {
  margin: 0;
  color: var(--text);
}

.algorithm-panel ul {
  padding-left: 20px;
}

.algorithm-panel li {
  margin: 6px 0;
}

.algorithm-panel pre {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  white-space: pre-wrap;
  color: #14532d;
}

.report-text {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfffd;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.55;
}

.report-summary {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint {
  width: 26px;
  min-height: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 240px));
}

.wide-field {
  grid-column: 1 / -1;
}

.employee-add-form button {
  grid-column: 4;
  justify-self: end;
  min-width: 130px;
}

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

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

th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  vertical-align: top;
}

th {
  color: #166534;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.history-item summary {
  background: #f7fdf9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
}

.history-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: 1;
}

.history-item[open] summary {
  border-bottom: 1px solid var(--line);
}

.history-item .table-wrap {
  padding: 4px 10px 12px;
}

.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--accent-soft);
  font-weight: 700;
}

.score.high {
  color: var(--ok);
}

.score.mid {
  color: var(--warn);
}

.score.low {
  color: var(--danger);
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.side-nav {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.side-nav .tab,
.nav-group .tab {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.nav-group {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.nav-group h2 {
  margin: 0 0 2px;
  color: #14532d;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-main {
  min-width: 0;
}

.tab {
  background: transparent;
  color: #166534;
  border: 1px solid var(--line);
}

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

.rating-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.rating-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.radio-line {
  display: flex;
  gap: 6px;
}

.radio-line button {
  flex: 1;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 8px;
}

.radio-line button.active {
  background: var(--accent-2);
  color: white;
}

.rating-table {
  min-width: 860px;
}

.rating-table th:not(:first-child),
.rating-table td:not(:first-child) {
  text-align: center;
}

.rating-table td:first-child {
  font-weight: 700;
  min-width: 190px;
}

.rating-table select {
  min-width: 132px;
}

.chart {
  width: 100%;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(#fff, #fff), repeating-linear-gradient(to top, transparent 0, transparent 51px, #dff3e8 52px);
}

.performance-chart {
  height: 320px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.notice {
  background: #fff8e1;
  color: #6f4e00;
  border: 1px solid #f6df99;
  border-radius: 8px;
  padding: 12px 14px;
}

.error {
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid #ffd4d0;
  border-radius: 8px;
  padding: 12px 14px;
}

@media (max-width: 820px) {
  .topbar {
    padding: 14px 16px;
    align-items: flex-start;
  }

  .admin-layout,
  .grid.two, .grid.three, .form-grid, .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
  }

  .employee-add-form button {
    grid-column: auto;
    justify-self: stretch;
  }

  .row {
    align-items: flex-start;
    flex-direction: column;
  }
}
