:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #dde3ea;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #be123c;
  --warning: #c2410c;
  --caution: #b45309;
  --ok: #047857;
  --expired: #111827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 750;
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav a,
.nav button,
.button-link,
.form-grid button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}

.nav button,
.form-grid button,
.button-link {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 1.65rem;
}

h2 {
  font-size: 1.05rem;
  margin-bottom: 12px;
}

p,
span {
  color: var(--muted);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-bar label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.filter-actions button,
.filter-actions a {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 9px 12px;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}

.filter-actions a {
  background: var(--panel);
  color: var(--accent-dark);
}

.deadline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 0 0 16px;
  font-size: 0.84rem;
}

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

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.project-card,
.login-panel,
.form-panel,
.table-section,
.note {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 156px;
  padding: 16px;
  text-decoration: none;
}

.project-card:hover {
  border-color: var(--accent);
}

.deadline-card-danger {
  border-left: 5px solid var(--danger);
}

.deadline-card-warning {
  border-left: 5px solid var(--warning);
}

.deadline-card-caution {
  border-left: 5px solid var(--caution);
}

.deadline-card-ok {
  border-left: 5px solid var(--ok);
}

.deadline-card-expired {
  border-left: 5px solid var(--expired);
}

.code,
.badge {
  color: var(--accent-dark);
  font-weight: 700;
}

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

.badge {
  width: fit-content;
  border: 1px solid #99d3cc;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.8rem;
}

.deadline-pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.2;
}

.deadline-danger,
.dot.deadline-danger {
  background: #ffe4e6;
  color: var(--danger);
}

.dot.deadline-danger {
  background: var(--danger);
}

.deadline-warning,
.dot.deadline-warning {
  background: #ffedd5;
  color: var(--warning);
}

.dot.deadline-warning {
  background: var(--warning);
}

.deadline-caution,
.dot.deadline-caution {
  background: #fef3c7;
  color: var(--caution);
}

.dot.deadline-caution {
  background: var(--caution);
}

.deadline-ok,
.dot.deadline-ok {
  background: #d1fae5;
  color: var(--ok);
}

.dot.deadline-ok {
  background: var(--ok);
}

.deadline-expired,
.dot.deadline-expired {
  background: #e5e7eb;
  color: var(--expired);
}

.dot.deadline-expired {
  background: var(--expired);
}

.deadline-neutral {
  background: #eef2f7;
  color: var(--muted);
}

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

.meta-grid div,
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.meta-grid span,
.kpi span {
  display: block;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.note {
  padding: 14px;
  margin-bottom: 18px;
}

.gauge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.gauge-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 16px;
}

.gauge-card h2 {
  margin: 0;
  text-align: center;
}

.gauge {
  --gauge-color: var(--accent);
  width: 184px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--panel) 0 57%, transparent 58%),
    conic-gradient(var(--gauge-color) var(--gauge-angle), #e5e7eb 0);
}

.gauge > div {
  display: grid;
  justify-items: center;
  gap: 3px;
  max-width: 132px;
  text-align: center;
}

.gauge strong {
  font-size: 1.55rem;
}

.gauge span {
  font-size: 0.76rem;
  line-height: 1.25;
}

.gauge-ok {
  --gauge-color: var(--ok);
}

.gauge-warning {
  --gauge-color: var(--warning);
}

.gauge-danger {
  --gauge-color: var(--danger);
}

.table-section {
  padding: 16px;
  margin-top: 16px;
}

.table-scroll {
  overflow: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 760px;
  font-size: 0.88rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

thead th {
  background: #eef3f6;
  font-weight: 700;
}

tbody tr:last-child {
  font-weight: 750;
}

.section-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-actions form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid p {
  display: grid;
  gap: 6px;
  margin: 0;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
}

.login-panel,
.form-panel {
  max-width: 520px;
  padding: 20px;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  padding: 10px 12px;
  border-radius: 6px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.back-link {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent-dark);
  text-decoration: none;
}

@media (max-width: 720px) {
  .topbar,
  .page-head,
  .section-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .shell {
    padding: 20px 14px 48px;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }
}
