:root {
  --bg: #ececf1;
  --surface: #f4f4f7;
  --surface-2: #ebebf0;
  --panel: #f0f0f4;
  --panel-soft: #f6f6f9;
  --text: #171823;
  --muted: #6f7383;
  --line: #dadbe4;
  --primary: #7d5cff;
  --primary-soft: #ece8ff;
  --accent: #1bb3a5;
  --danger: #e35da6;
  --ok: #1aa58f;
  --shadow: 0 1px 0 rgba(20, 24, 40, 0.02), 0 10px 22px rgba(20, 24, 40, 0.03);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Manrope", "Segoe UI", Roboto, -apple-system, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f0f0f5 0%, #ececf1 100%);
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1680px;
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 22px;
  background: rgba(246, 246, 250, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

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

.nav a {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: #4d5160;
  font-weight: 700;
}

.nav a.active {
  background: var(--primary-soft);
  color: #5f45cc;
  border-color: #dfd7ff;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 700;
  color: #6b4eff;
  background: #ece8ff;
  border: 1px solid #ddd3ff;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  color: #555a6a;
  background: #ededf3;
  border: 1px solid #dbdde8;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #d5d7e5;
  background: #f8f8fc;
  color: #4f5568;
  font-size: 19px;
  line-height: 1;
}

.icon-btn.active {
  background: var(--primary-soft);
  color: #6248ce;
  border-color: #d8ceff;
}

h1 {
  margin: 4px 0 16px;
  font-size: clamp(34px, 3.2vw, 54px);
  line-height: 1.06;
  letter-spacing: -0.02em;
}

h2 {
  margin: 6px 0 14px;
  font-size: clamp(24px, 2vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

h3 {
  margin: 14px 0 10px;
  font-size: 22px;
  line-height: 1.15;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

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

.filters {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

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

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #e0e1ea;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--panel-soft);
  color: #1e2230;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #c8bbff;
  box-shadow: 0 0 0 3px rgba(125, 92, 255, 0.12);
  background: #fbfaff;
}

input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #cfd2e2;
  box-shadow: none;
}

input[type="checkbox"]:focus {
  box-shadow: 0 0 0 3px rgba(125, 92, 255, 0.18);
}

input[type="file"] {
  border-radius: 14px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 20px;
  border-radius: 999px;
  border: 1px solid #dfdfea;
  background: var(--panel-soft);
  padding: 10px 14px;
  color: #555a6a;
  font-weight: 700;
}

.check input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
}

.btn {
  border: 1px solid #d8dae7;
  background: #e4e5eb;
  color: #494f5f;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.btn:hover {
  filter: brightness(0.985);
  text-decoration: none;
}

.btn.primary {
  background: var(--accent);
  border-color: #16a194;
  color: #ffffff;
}

.btn.warning {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.actions .btn.warning {
  background: #e8e8ee;
  border-color: #d7d9e4;
  color: #4f5566;
}

.btn.danger {
  background: #ffeaf5;
  border-color: #f5b0d7;
  color: #b42e78;
}

.btn.tiny {
  font-size: 13px;
  padding: 7px 12px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 8px 12px 14px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: separate;
  border-spacing: 0 10px;
}

thead th {
  border: 0;
  padding: 10px 12px;
  color: #565b6b;
  font-size: 13px;
  font-weight: 800;
  text-transform: none;
  letter-spacing: 0.01em;
}

tbody td {
  border: 0;
  padding: 13px 12px;
  vertical-align: middle;
  background: var(--panel-soft);
  color: #1f2332;
  font-size: 17px;
}

tbody tr td:first-child {
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
}

tbody tr td:last-child {
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px;
}

.expired {
  color: var(--danger);
  font-weight: 800;
}

.expiring {
  color: #9a7b00;
  font-weight: 800;
}

tr.row-expired td {
  background: #ffeef5;
}

tr.row-expiring td {
  background: #fff8dc;
}

.flash {
  padding: 12px 15px;
  border-radius: 16px;
  margin-bottom: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.flash.ok {
  background: #eafbf5;
  border-color: #bcefe1;
  color: #0f7d6f;
}

.flash.err {
  background: #ffeff6;
  border-color: #f8c9df;
  color: #b83074;
}

.links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 780px;
  margin: 0;
  font-size: 12px;
  color: #4a4e5e;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 20% 10%, #f7f3ff 0%, #ececf2 55%, #e9e9ef 100%);
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px;
  border-radius: 28px;
  border: 1px solid #dddeea;
  background: #f3f3f8;
  box-shadow: var(--shadow);
}

.settings-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
}

.settings-sidebar {
  position: sticky;
  top: 84px;
  height: fit-content;
}

.settings-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.settings-nav {
  display: grid;
  gap: 8px;
}

.settings-nav a,
.settings-nav .disabled {
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid #daddeb;
  background: #efeff4;
  color: #545a6a;
  font-weight: 700;
}

.settings-nav a.active {
  background: var(--primary-soft);
  border-color: #d8ccff;
  color: #6248ce;
}

.settings-nav .disabled {
  color: #a0a5b5;
}

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

.stat-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
}

.stat-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-value {
  margin-top: 4px;
  font-size: 28px;
  font-weight: 800;
}

@media (max-width: 1200px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 980px) {
  .container {
    padding: 14px;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-sidebar {
    position: static;
  }

  .panel {
    border-radius: 20px;
    padding: 14px;
  }

  tbody td {
    font-size: 15px;
  }

  .btn {
    width: 100%;
  }

  .inline-controls .btn {
    width: auto;
  }
}

.deleted-label {
  text-decoration: line-through;
  color: #7a7a7a;
}

.row-deleted td {
  background: #f4f4f4;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #e9e2ff;
  color: #5d3dd1;
  margin-left: 6px;
}

dialog {
  border: 1px solid #d0d0d0;
  border-radius: 12px;
  padding: 16px;
  max-width: 700px;
  width: 90%;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-row {
  justify-content: space-between;
  margin-bottom: 10px;
}

.judge-activity-toolbar {
  margin-top: 12px;
  margin-bottom: 12px;
}

.two-col {
  grid-template-columns: 1fr 1fr;
}
