@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap");

:root {
  --bg: #f3f0ff;
  --surface: #ffffff;
  --ink: #1e1635;
  --muted: #6b6285;
  --line: #e8e2f5;
  --brand: #5b21b6;
  --brand-2: #7c3aed;
  --brand-3: #a78bfa;
  --brand-soft: #ede9fe;
  --sidebar: #2e1065;
  --sidebar-2: #4c1d95;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --shadow: 0 10px 30px rgba(46, 16, 101, 0.08);
  --shadow-lg: 0 24px 60px rgba(46, 16, 101, 0.16);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "DM Sans", "Segoe UI", sans-serif;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--brand-2); text-decoration: none; }

img { max-width: 100%; display: block; }

button, input, select, textarea { font: inherit; }

/* —— Icons —— */
.icon {
  width: 1.15em;
  height: 1.15em;
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-lg { width: 1.5rem; height: 1.5rem; }

/* —— App shell —— */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.35rem 1rem;
  background:
    radial-gradient(500px 280px at 0% 0%, rgba(167, 139, 250, 0.35), transparent 60%),
    linear-gradient(180deg, var(--sidebar-2), var(--sidebar));
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.sidebar-brand strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  display: block;
  font-size: 0.78rem;
  opacity: 0.75;
  margin-top: 0.1rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 600;
  font-size: 0.95rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.95), rgba(91, 33, 182, 0.95));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.sidebar-foot {
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-title h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.page-title p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 8px 18px rgba(91, 33, 182, 0.28);
}

.user-meta strong {
  display: block;
  font-size: 0.92rem;
}

.user-meta span {
  color: var(--muted);
  font-size: 0.8rem;
}

.content {
  padding: 1.35rem 1.5rem 2.5rem;
  width: min(1200px, 100%);
}

.hero-banner {
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.15rem;
  color: #fff;
  background:
    radial-gradient(600px 200px at 100% 0%, rgba(167, 139, 250, 0.45), transparent 55%),
    linear-gradient(135deg, #5b21b6, #7c3aed 55%, #6d28d9);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-banner h2 {
  margin: 0 0 0.3rem;
  font-size: 1.35rem;
}

.hero-banner p {
  margin: 0;
  opacity: 0.9;
  font-size: 0.95rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid-2 {
  grid-template-columns: 1.35fr 1fr;
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    padding: 1rem;
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-link { width: auto; }
  .sidebar-foot { flex-direction: row; flex-wrap: wrap; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1.2rem 1.3rem 0.4rem;
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  flex-shrink: 0;
}

.card-icon.ok { background: var(--ok-soft); color: var(--ok); }
.card-icon.warn { background: #fef3c7; color: var(--warn); }

.card-head h2,
.panel-title {
  margin: 0;
  font-size: 1.05rem;
}

.card-head p,
.panel-sub {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.card-body {
  padding: 1rem 1.3rem 1.3rem;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 1rem;
}

@media (max-width: 800px) {
  .stat-cards { grid-template-columns: 1fr; }
}

.stat-card {
  padding: 1rem 1.1rem;
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.stat-card strong {
  display: block;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

/* —— Forms / buttons —— */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.14);
}

.field { margin-bottom: 1rem; }

.field-icon {
  position: relative;
}

.field-icon .icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.field-icon input {
  padding-left: 2.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1.15rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 22px rgba(91, 33, 182, 0.28);
}

.btn-block { width: 100%; }

.btn-ghost {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn-ghost.on-dark {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ok {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 10px 22px rgba(5, 150, 105, 0.28);
}

.btn-sm {
  padding: 0.5rem 0.85rem;
  font-size: 0.88rem;
}

.alert {
  display: none;
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  font-size: 0.9rem;
}

.alert.show { display: flex; align-items: center; gap: 0.5rem; }
.alert-error { background: var(--danger-soft); color: #991b1b; }
.alert-ok { background: var(--ok-soft); color: #065f46; }

/* —— Dashboard clock —— */
.hero-panel {
  padding: 1.6rem;
  text-align: center;
  background:
    radial-gradient(500px 220px at 50% 0%, rgba(237, 233, 254, 0.9), transparent 70%),
    #fff;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand);
  margin-bottom: 1rem;
}

.status-pill.live {
  background: var(--ok-soft);
  color: #047857;
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.15);
}

.timer {
  font-size: clamp(2.6rem, 8vw, 4rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  margin: 0.4rem 0 1.2rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.clock-btn {
  min-width: 220px;
  font-size: 1.05rem;
  padding: 1rem 1.5rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  font-weight: 650;
}

.tab.active {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.stat-row:last-child { border-bottom: 0; }
.stat-row strong { font-variant-numeric: tabular-nums; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-active { background: var(--ok-soft); color: #047857; }
.badge-done { background: var(--brand-soft); color: var(--brand); }

.empty {
  color: var(--muted);
  padding: 1.4rem 0;
  text-align: center;
}

.muted { color: var(--muted); }

/* —— Auth / login —— */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.auth-hero {
  position: relative;
  overflow: hidden;
  padding: 2.5rem;
  color: #fff;
  background:
    radial-gradient(700px 400px at 20% 20%, rgba(167, 139, 250, 0.45), transparent 60%),
    linear-gradient(160deg, #4c1d95, #5b21b6 40%, #7c3aed);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth-hero::after {
  content: "";
  position: absolute;
  inset: auto -20% -30% 20%;
  height: 60%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), transparent 65%);
  pointer-events: none;
}

.auth-hero-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  position: relative;
  z-index: 1;
}

.auth-hero-brand img {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.auth-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
  letter-spacing: -0.03em;
  position: relative;
  z-index: 1;
  max-width: 12ch;
}

.auth-hero p {
  margin: 0.85rem 0 0;
  opacity: 0.9;
  font-size: 1.05rem;
  max-width: 34ch;
  position: relative;
  z-index: 1;
}

.auth-features {
  display: grid;
  gap: 0.75rem;
  position: relative;
  z-index: 1;
}

.auth-feature {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  font-weight: 600;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
  background:
    radial-gradient(500px 240px at 90% 10%, rgba(196, 181, 253, 0.35), transparent 60%),
    #f8f5ff;
}

.auth-card {
  width: min(420px, 100%);
  padding: 2rem;
}

.auth-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.auth-card .sub {
  margin: 0 0 1.4rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { min-height: 280px; padding: 1.5rem; }
  .auth-hero h1 { max-width: none; font-size: 1.8rem; }
}

/* —— Modal —— */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 22, 53, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-backdrop.show { display: flex; }

.modal {
  width: min(440px, 100%);
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.modal-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
}

.modal-head .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.modal-actions .btn { flex: 1; }
.modal-actions .btn-primary { width: auto; }

.mobile-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, var(--sidebar-2), var(--sidebar));
  color: #fff;
}

.mobile-bar img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom));
  justify-content: space-around;
  gap: 0.15rem;
  box-shadow: 0 -8px 24px rgba(46, 16, 101, 0.08);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.45rem 0.2rem;
  min-height: 52px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 10px;
}

.bottom-nav a .icon { width: 1.35rem; height: 1.35rem; }
.bottom-nav a.active,
.bottom-nav a:hover { color: var(--brand); background: var(--brand-soft); }

.bar-chart { display: flex; flex-direction: column; gap: 0.65rem; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(72px, 110px) 1fr 48px;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.85rem;
}
.bar-label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track {
  height: 10px;
  background: var(--brand-soft);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 999px;
  min-width: 2px;
}
.bar-value { text-align: right; font-weight: 600; }

.btn.on-dark {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.btn.on-dark:hover { background: rgba(255, 255, 255, 0.2); }

@media (max-width: 980px) {
  .mobile-bar { display: flex; }

  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main {
    min-width: 0;
  }

  .content {
    padding: 1rem 1rem 5.5rem;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .stat-cards {
    grid-template-columns: 1fr;
  }

  .hero-panel .timer {
    font-size: 2.4rem;
  }

  .clock-btn,
  .btn {
    min-height: 44px;
  }

  .bottom-nav { display: flex; }

  .auth-wrap {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    padding: 1.5rem 1.25rem 1rem;
    min-height: auto;
  }

  .auth-hero h1 { font-size: 1.55rem; }
  .auth-features { display: none; }
  .auth-panel { padding: 0 1rem 2rem; }
  .auth-card { padding: 1.25rem; }

  .bar-row {
    grid-template-columns: 64px 1fr 40px;
    font-size: 0.78rem;
  }

  table { font-size: 0.85rem; }
  th, td { padding: 0.55rem 0.45rem; }
}
