:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #d9e0ec;
  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --ok: #0f766e;
  --warn: #b45309;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 18px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 18px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
}

.page.wide {
  max-width: none;
}

.hero,
.toolbar,
.summary,
.empty,
.login-card,
.report-card,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.hero {
  padding: 28px;
  margin-bottom: 22px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 32px;
}

.hero p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.55;
}

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

.report-card {
  padding: 20px;
}

.report-card.ready {
  border-color: rgba(15, 118, 110, 0.35);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.card-head h2 {
  margin: 0;
  font-size: 20px;
}

.status {
  white-space: nowrap;
  color: var(--ok);
  background: rgba(15, 118, 110, 0.1);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.report-card:not(.ready) .status {
  color: var(--warn);
  background: rgba(180, 83, 9, 0.1);
}

dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
}

.card-actions,
.toolbar,
.summary,
.period-form,
.top-actions,
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.card-actions {
  margin-top: 16px;
}

.card-actions a,
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.button:hover,
.card-actions a:hover {
  background: var(--accent-dark);
  text-decoration: none;
}

button.secondary,
.button.secondary,
.card-actions a + a {
  color: var(--text);
  background: #e8eef8;
}

button.secondary:hover,
.button.secondary:hover,
.card-actions a + a:hover {
  background: #dbe5f5;
}

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

input,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

.top-actions,
.toolbar-actions {
  align-items: center;
}

.top-actions form {
  margin: 0;
}

.users-page {
  display: grid;
  gap: 20px;
  max-width: 1120px;
}

.panel {
  padding: 22px;
}

.panel h1,
.panel h2 {
  margin-top: 0;
}

.user-form {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) minmax(160px, 0.5fr) auto;
  align-items: end;
}

.success {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--ok);
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.2);
}

.compact-table {
  max-height: 420px;
}

.user-list {
  display: grid;
  gap: 12px;
}

.user-edit-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(190px, 1fr) minmax(150px, 0.65fr) minmax(160px, 0.8fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
}

.user-meta {
  display: grid;
  gap: 5px;
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}

.current-user {
  color: var(--ok);
  font-weight: 700;
}

.user-actions {
  display: flex;
  gap: 8px;
}

button.danger {
  color: var(--danger);
  background: rgba(185, 28, 28, 0.1);
}

button.danger:hover {
  color: #fff;
  background: var(--danger);
}

.toolbar {
  justify-content: space-between;
  padding: 16px;
  margin-bottom: 16px;
}

.summary {
  padding: 12px 16px;
  margin-bottom: 16px;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3fb;
  font-weight: 800;
}

tr:hover td {
  background: #f8fbff;
}

.alert {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--danger);
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.2);
}

.empty {
  padding: 24px;
  color: var(--muted);
}

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

.login-card {
  width: min(420px, 100%);
  padding: 28px;
}

.login-card h1 {
  margin-bottom: 4px;
}

.form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.back {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--muted);
}

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

  .page {
    padding: 16px;
  }

  .user-form {
    grid-template-columns: 1fr;
  }

  .user-edit-form {
    grid-template-columns: 1fr;
  }
}
