:root {
  --bg: #0b0d12;
  --bg-elev: #161922;
  --bg-elev-2: #1f2330;
  --border: #2a2f3d;
  --text: #f4f6fb;
  --muted: #9aa3b8;
  --accent: #00a5b1;
  --accent-strong: #1bbcc8;
  --accent-soft: rgba(0, 165, 177, 0.15);
  --danger: #ff5d5d;
  --warn: #ffb020;
  --negative: #ff6b9a;
  --ok: #4ddc89;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* --- Site header --- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 13, 18, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.site-header .brand img {
  height: 38px;
  display: block;
}
.site-header .brand:hover {
  text-decoration: none;
  opacity: 0.85;
}
.site-header .clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

@media (max-width: 540px) {
  .site-header {
    padding: 10px 14px;
  }
  .site-header .brand img {
    height: 30px;
  }
  .site-header .clock {
    font-size: 0.9rem;
  }
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}
.container.wide {
  max-width: 1200px;
}

.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 1.1rem;
}
.back-link {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

/* --- Homepage big campus buttons --- */
.campus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin: 28px 0;
}
.campus-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 130px;
  padding: 28px 24px;
  background: var(--bg-elev);
  border: 2px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  transition: transform 0.1s ease, border-color 0.15s ease,
    background 0.15s ease, box-shadow 0.15s ease;
}
.campus-grid a:hover {
  text-decoration: none;
  border-color: var(--accent);
  background: var(--bg-elev-2);
  box-shadow: 0 6px 24px var(--accent-soft);
  transform: translateY(-2px);
}

/* --- Cards / forms --- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 22px;
}
.card h2 {
  margin-top: 0;
  margin-bottom: 4px;
}
.card-sub {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 0.95rem;
}

h2 {
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  font-weight: 600;
}

.timer-form {
  display: grid;
  gap: 12px;
}
.timer-form label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--muted);
}
.timer-form input[type="text"],
.timer-form input[type="number"],
.timer-form input[type="password"] {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.15rem;
  padding: 11px 14px;
  border-radius: 10px;
  font-family: inherit;
  width: 100%;
}
.timer-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.checkbox-row {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.checkbox-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  margin: 0;
}
.checkbox-row .hint {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}
button.btn,
.timer-form button {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  border: none;
  padding: 12px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: inherit;
}
button.btn:hover,
.timer-form button:hover {
  background: var(--accent-strong);
}
button.btn:disabled,
.timer-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 7px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}
button.btn-danger:hover {
  background: var(--danger);
  color: #1a0707;
}
.form-error {
  color: var(--danger);
  margin: 0;
  min-height: 1.2em;
  font-size: 0.95rem;
}

/* --- Timer cards --- */
.timer-list {
  display: grid;
  gap: 12px;
}
.timer-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 6px solid var(--accent);
  border-radius: 14px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
}
.timer-card.warn {
  border-left-color: var(--warn);
}
.timer-card.danger {
  border-left-color: var(--danger);
}
.timer-card.negative {
  border-left-color: var(--negative);
}
.timer-card .name {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.timer-card .meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 2px 0 0;
}
.timer-card .countdown {
  font-variant-numeric: tabular-nums;
  font-size: clamp(2rem, 5.5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.timer-card.negative .countdown {
  color: var(--negative);
}

.empty {
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
}

/* --- PM dashboard --- */
.pm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}
.pm-campus {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pm-campus h3 {
  margin: 0;
  font-size: 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.pm-campus h3 .title-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.pm-campus h3 .count {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.pm-campus h3 .add-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}
.pm-campus h3 .add-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}
.pm-campus h3 .add-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pm-timers {
  display: flex;
  flex-direction: column;
}
.pm-campus .pm-timer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  gap: 10px;
}
.pm-campus .pm-timer:first-of-type {
  border-top: none;
}
.pm-campus .pm-timer .pm-name {
  font-size: 1rem;
  font-weight: 600;
  word-break: break-word;
}
.pm-campus .pm-timer .pm-count {
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.pm-campus .pm-timer.negative .pm-count {
  color: var(--negative);
}
.pm-campus .pm-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2px 0;
}
/* --- Modal dialog --- */
.modal {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elev);
  color: var(--text);
  padding: 22px;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.modal::backdrop {
  background: rgba(5, 7, 12, 0.65);
  backdrop-filter: blur(2px);
}
.modal h2 {
  margin: 0 0 14px;
}
.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}
.btn-ghost {
  background: transparent !important;
  color: var(--muted) !important;
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-elev-2) !important;
  color: var(--text) !important;
}

/* --- Auth gate --- */
.auth-gate {
  max-width: 440px;
  margin: 48px auto 0;
}

@media (max-width: 540px) {
  body {
    font-size: 17px;
  }
  .container {
    padding: 22px 16px 48px;
  }
  .timer-card {
    grid-template-columns: 1fr;
  }
  .timer-card .countdown {
    justify-self: end;
  }
  .campus-grid a {
    min-height: 110px;
    font-size: 1.4rem;
  }
}
