/* ════════════════════════════════════════════════════════════════════
   Cronos — style.css
   Dark minimalist theme · Glassmorphism · Flip clock
   ══════════════════════════════════════════════════════════════════ */

/* ── Reset & tokens ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Login Overlay ───────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.login-overlay.fade-out {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

#login-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.45;
}

.login-card {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 48px 40px 40px;
  border-radius: 24px;
  background: rgba(18, 18, 18, 0.65);
  backdrop-filter: blur(40px) saturate(1.4);
  -webkit-backdrop-filter: blur(40px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6),
              0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  width: 90vw;
  max-width: 380px;
  animation: login-card-in 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes login-card-in {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.login-logo {
  color: rgba(255, 255, 255, 0.6);
  animation: login-logo-pulse 3s ease-in-out infinite;
}

@keyframes login-logo-pulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

.login-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.02em;
  color: #e8e8e8;
}

.login-subtitle {
  font-size: 13px;
  color: #555;
  letter-spacing: 0.01em;
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 44px 14px 16px;
  font-size: 15px;
  color: #e8e8e8;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
  outline: none;
}
.login-input::placeholder { color: #444; }
.login-input:focus {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}
.login-input.shake {
  animation: login-shake 0.45s ease;
}

@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  15%      { transform: translateX(-8px); }
  30%      { transform: translateX(6px); }
  45%      { transform: translateX(-4px); }
  60%      { transform: translateX(2px); }
  75%      { transform: translateX(-1px); }
}

.login-eye {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: #444;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: color 0.2s;
}
.login-eye:hover { color: #888; }

.login-error {
  font-size: 12px;
  color: #f87171;
  min-height: 16px;
  text-align: center;
  transition: opacity 0.2s;
}

.login-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: #fff;
  color: #111;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s, transform 0.15s;
}
.login-btn:hover { background: #ececec; }
.login-btn:active { transform: scale(0.97); }
.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: #111;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
.login-spinner.hidden { display: none; }

:root {
  --bg:        #0e0e0e;
  --bg-2:      #111;
  --bg-3:      #141414;
  --bg-4:      #1a1a1a;
  --border:    #1e1e1e;
  --border-2:  #252525;
  --text:      #e8e8e8;
  --text-2:    #888;
  --text-3:    #444;
  --green:     #4ade80;
  --green-dim: #2a6e3f;
  --blue:      #3b82f6;
  --purple:    #a855f7;
  --amber:     #f59e0b;
  --red:       #f87171;
  --sidebar-w: 200px;
  --sidebar-w-collapsed: 56px;
  --radius:    14px;
  --radius-sm: 10px;
  --transition: 0.32s cubic-bezier(0.4,0,0.2,1);
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 99px; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* ── Layout ──────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100dvh;
}

#main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 72px; /* bottom-nav height */
}

#view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  display: none; /* hidden on mobile */
  flex-direction: column;
  flex-shrink: 0;
  width: var(--sidebar-w);
  min-height: 100dvh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  align-self: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition);
}
/* hide scrollbar */
.sidebar::-webkit-scrollbar { display: none; }
.sidebar { -ms-overflow-style: none; scrollbar-width: none; }

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-item:hover { background: var(--bg-3); color: var(--text-2); }
.sidebar-item.active { background: #1f1f1f; color: var(--text); }

.sidebar-toggle-btn {
  color: var(--text-3);
}

.sidebar-icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-label {
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.18s ease;
}

.sidebar.collapsed .sidebar-label { opacity: 0; pointer-events: none; }
.sidebar.collapsed .sidebar-footer { opacity: 0; }
.sidebar.collapsed .sidebar-settings-panel,
.sidebar.collapsed .sidebar-settings-btn { display: none !important; }

.sidebar-brand {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--text);
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.sidebar-footer {
  padding: 0 16px 24px;
  margin-top: auto;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: opacity 0.2s ease;
}

.footer-by { color: var(--text-3); margin-right: 4px; }

/* ── Bottom nav (mobile) ──────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 0 12px;
  background: rgba(14,14,14,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 40;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  transition: color 0.15s;
}

.bottom-nav-item.active { color: var(--text); }

/* ── Page wrapper ─────────────────────────────────────────────────── */
.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 72px);
  padding: 32px 16px;
  gap: 32px;
}

.page-wide {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 72px);
  padding: 28px 24px;
  gap: 20px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

/* ── Flip clock ──────────────────────────────────────────────────── */
.clock {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.2vw, 20px);
}

.digit-group { display: flex; gap: clamp(4px, 0.6vw, 10px); }

.flip-card {
  position: relative;
  width: clamp(68px, 14vw, 130px);
  height: clamp(86px, 17vw, 158px);
  border-radius: var(--radius);
  background: #1c1c1c;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.04);
}

.fc-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: inherit;
  will-change: transform;
}

.fc-digit {
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: clamp(2.8rem, 9vw, 7.5rem);
  letter-spacing: -0.04em;
  color: #e8e8e8;
  user-select: none;
  pointer-events: none;
  line-height: 1;
}

.fc-divider {
  position: absolute;
  top: 50%; left: 5px; right: 5px;
  height: 2px;
  background: rgba(0,0,0,0.55);
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 2;
}

/* Colon separator */
.colon {
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1vw, 10px);
  align-items: center;
  justify-content: center;
  padding-bottom: 4px;
  color: #282828;
  font-size: clamp(1rem, 3vw, 2.4rem);
  font-weight: 300;
  min-width: clamp(10px, 1.6vw, 20px);
  transition: color 0.5s ease;
}
.colon.running { color: var(--green-dim); }
.colon.break { color: var(--purple); }

/* Subject glass card */
.subject-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  min-width: 140px;
}
.subject-chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.subject-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.subject-name {
  font-size: 14px;
  font-weight: 500;
  color: #bbb;
  transition: opacity 0.28s ease;
}
.subject-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--text-3);
  transition: color 0.5s ease;
}
.subject-status.running { color: var(--green-dim); }
.subject-status.paused  { color: #6e5a2a; }
.subject-status.break   { color: var(--purple); }

.eye-btn {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  color: var(--text-3);
  transition: color 0.2s;
}
.eye-btn:hover { color: var(--text-2); }

/* Timer buttons */
.btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none;
  transition: transform 0.15s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary {
  background: #fff; color: #111;
  padding: 16px 44px;
  font-size: 15px;
}
.btn-primary:hover { background: #ececec; }

.btn-pause {
  background: #2a1e00; color: var(--amber);
  padding: 13px 24px;
  border: 1px solid #3a2e00;
}
.btn-pause:hover { background: #3a2800; }

.btn-stop {
  background: #1f0a0a; color: var(--red);
  padding: 13px 24px;
  border: 1px solid #3a1414;
}
.btn-stop:hover { background: #2a0e0e; }

.btn-resume {
  background: #0d1f0e; color: var(--green);
  padding: 13px 24px;
  border: 1px solid #1a4a1b;
}
.btn-resume:hover { background: #112614; }

.btn-reset {
  background: var(--bg-4); color: var(--text-3);
  padding: 13px 14px;
  border: 1px solid var(--border-2);
}
.btn-reset:hover { color: var(--text-2); }

.btn-ghost {
  background: var(--bg-4); color: var(--text-2);
  padding: 10px 20px;
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { background: #222; }

.btn-danger {
  background: #1f0a0a; color: var(--red);
  padding: 10px 20px;
  border: 1px solid #3a1414;
}
.btn-danger:hover { background: #2a0e0e; }

/* Config card */
.config-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.config-card-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-weight: 500;
  color: var(--text-3);
  text-align: center;
}

/* Quality stars */
.stars { display: flex; gap: 4px; }
.star-btn {
  transition: transform 0.15s;
}
.star-btn:hover { transform: scale(1.15); }
.star-btn svg { transition: fill 0.15s, stroke 0.15s; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.2);
}
.form-input::placeholder { color: var(--text-3); }

.form-textarea {
  resize: none;
  rows: 2;
}

/* Type pills */
.type-pills { display: flex; gap: 8px; }
.type-pill {
  flex: 1;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.type-pill.active { background: #fff; color: #111; border-color: #fff; }
.type-pill:hover:not(.active) { color: var(--text-2); }

/* Subject list in config */
.subj-list { display: flex; flex-direction: column; gap: 4px; }
.subj-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  font-size: 13px;
  color: var(--text-3);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.subj-btn.active {
  background: #1e1e1e;
  border-color: #2e2e2e;
  color: var(--text);
}
.subj-btn:hover:not(.active) { color: var(--text-2); }

/* Notes toggle */
.notes-toggle {
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.15s;
}
.notes-toggle:hover { color: var(--text-2); }

/* ── Subjects page ────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 4px;
}

.subject-list { display: flex; flex-direction: column; gap: 10px; }

.subject-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}
.subject-card:hover { border-color: var(--border-2); }

.subject-color-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.subject-info { flex: 1; min-width: 0; }
.subject-info-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subject-info-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.subject-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text-2); background: #222; }
.icon-btn.danger:hover { color: var(--red); border-color: #3a1414; background: #1f0a0a; }

/* Color picker*/
.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #fff; }

/* ── Dashboard — Grafana style ───────────────────────────────────── */
.dash-root {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  min-height: calc(100dvh - 72px);
}

.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.dash-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.dash-subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.dash-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-3);
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.sync-badge.live {
  color: var(--green);
  border-color: rgba(74, 222, 128, 0.2);
  background: rgba(74, 222, 128, 0.05);
}

.dash-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
}
.dash-refresh-btn:hover { color: var(--text); }
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

/* KPI row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.kpi-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s;
}
.kpi-card:hover { border-color: var(--border-2); }
.kpi-card.accent-blue { border-top: 2px solid var(--blue); }
.kpi-card.accent-purple { border-top: 2px solid var(--purple); }
.kpi-card.accent-amber { border-top: 2px solid var(--amber); }
.kpi-card.accent-green { border-top: 2px solid var(--green); }

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
}
.kpi-icon {
  color: var(--text-3);
  display: flex;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
}
.kpi-context {
  font-size: 11px;
  color: var(--text-3);
}

/* Panels grid */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.dash-row {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
}

.panel {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.panel-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.panel-meta {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--border);
  padding: 2px 6px;
  border-radius: 4px;
}

.panel-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-3);
}

.panel-subtitle {
  font-size: 11px;
  color: #333;
}

.panel-chart-wrap {
  position: relative;
  overflow: hidden;
}
.panel-donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}
.donut-legend {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.donut-legend-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
}
.donut-legend-row span:last-child {
  font-weight: 600;
  color: var(--text);
}

/* Responsive dashboard */
@media (max-width: 720px) {
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-row {
    grid-template-columns: 1fr;
  }
  .dash-root { padding: 16px; }
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-3);
  text-align: center;
}
.empty-state svg { opacity: 0.3; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-2); }
.empty-state-body  { font-size: 14px; }

/* ── Modal ────────────────────────────────────────────────────────── */
dialog.modal {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 100vw;
  max-height: 100vh;
}

dialog.modal::backdrop {
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.modal-box {
  background: #171717;
  border: 1px solid #232323;
  border-radius: 18px;
  padding: 0;
  width: 90vw;
  max-width: 480px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.8);
  overflow: hidden;
  animation: modal-in 0.28s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 16px; font-weight: 700; color: var(--text); }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  background: var(--bg-4);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.modal-close:hover { color: var(--text); background: #222; }

.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
}

.confirm-text {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ── Mini timer ───────────────────────────────────────────────────── */
.mini-timer {
  position: fixed;
  bottom: 80px;
  left: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: rgba(20,20,20,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(74,222,128,0.2);
  box-shadow: 0 4px 20px rgba(74,222,128,0.08);
  cursor: pointer;
  transition: border-color 0.4s, box-shadow 0.4s;
}
.mini-timer.paused {
  border-color: rgba(245,158,11,0.2);
  box-shadow: 0 4px 20px rgba(245,158,11,0.08);
}
.mini-timer.hidden { display: none; }

.mini-timer-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}
.mini-timer.paused .mini-timer-dot {
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
  animation: none;
}

.mini-timer-time {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}
.mini-timer.paused .mini-timer-time { color: var(--amber); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Toast ────────────────────────────────────────────────────────── */
.toast-root {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  align-items: center;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: #1c1c1c;
  border: 1px solid #2a2a2a;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  font-size: 14px;
  color: var(--text);
  pointer-events: auto;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
  white-space: nowrap;
}

@keyframes toast-in  { from { opacity:0; transform:translateY(-12px); } to { opacity:1; transform:translateY(0); } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; transform:translateY(-8px); } }

/* ── Stale warning ────────────────────────────────────────────────── */
.stale-warning {
  position: fixed;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: #1a1200;
  border: 1px solid #3a2800;
  max-width: 90vw;
}
.stale-text { font-size: 13px; color: #fef08a; flex: 1; }
.stale-close { font-size: 14px; color: var(--amber); cursor: pointer; }

/* ── Loader ───────────────────────────────────────────────────────── */
.loader {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  color: var(--text-3);
  font-size: 14px;
  gap: 10px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-2);
  border-top-color: var(--text-3);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.gap-1 { gap: 4px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (min-width: 768px) {
  .sidebar { display: flex; }
  .bottom-nav { display: none; }
  #main { padding-bottom: 0; }
  #view { min-height: 100dvh; }
  #mini-timer { bottom: 24px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .page-wide { padding: 20px 16px; }
  
  /* Reduzir tamanho dos flip cards no mobile */
  .flip-card { width: 52px; height: 72px; }
  .fc-digit { font-size: 2.2rem; }
  .colon { font-size: 1.4rem; gap: 4px; min-width: 8px; }
  .clock { gap: 6px; }
}



/* ── Subject History Accordion ───────────────────────────────────── */
.subject-item-wrap {
  display: flex;
  flex-direction: column;
}
.history-accordion {
  overflow: hidden;
  height: 0;
}
.history-accordion-inner {
  padding: 12px 18px;
  background: var(--bg-4);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  border: 1px solid var(--border);
  border-top: none;
  font-size: 12px;
  color: var(--text-3);
}
.history-toggle {
  width: 100%;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  padding: 8px 18px;
  background: var(--bg-3);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.history-toggle:hover { background: var(--bg-4); color: var(--text-2); }
.history-table {
  width: 100%;
  border-collapse: collapse;
}
.history-table th, .history-table td {
  padding: 6px 0;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.history-table th { font-weight: 500; color: var(--text-2); }

.history-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 0 4px 18px;
  width: 100%;
}
.history-toggle:hover { color: var(--text-1); }
.history-chevron { flex-shrink: 0; }

/* ── Dashboard Period Selector ───────────────────────────────────── */
.period-selector { display: flex; gap: 2px; }
.period-btn {
  background: transparent;
  border: 0.5px solid transparent;
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 7px;
  transition: all 0.15s;
}
.period-btn:hover { color: var(--text-1); }
.period-btn.active {
  border-color: var(--border);
  color: var(--text-1);
  background: var(--bg-2);
}

/* ── Timer Two Columns Layout ────────────────────────────────────── */
@media (min-width: 900px) {
  .timer-page {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr;
    gap: 0 48px;
    align-items: start;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
  }
  .timer-page .subject-chip { grid-column: 1; justify-self: center; margin-top: 40px; }
  .timer-page .clock-wrap   { grid-column: 1; justify-self: center; margin-top: 20px; }
  .timer-page .btn-row      { grid-column: 1; justify-self: center; margin-top: 20px; }
  .timer-page .stale-warning{ grid-column: 1 / -1; }
  .timer-page .config-card  { grid-column: 2; grid-row: 1 / 4; justify-self: start; margin-top: 40px; }
}

/* ── Sidebar Settings Panel ──────────────────────────────────────── */
.sidebar-settings-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-settings-btn:hover {
  background: var(--bg-3);
  color: var(--text-1);
}
.sidebar-settings-panel {
  overflow: hidden;
  height: 0;
  padding: 0 12px;
}
.sidebar-settings-inner {
  font-size: 13px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.sidebar-settings-row {
  display: flex;
  gap: 8px;
}
#sidebar-goal-input {
  flex: 1;
  width: 100%;
  background: var(--bg-4);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
}
#sidebar-goal-input:focus { border-color: rgba(255,255,255,0.3); }

/* ── Fullscreen Button ───────────────────────────────────────────── */
.fullscreen-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 90;
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.fullscreen-btn:hover {
  background: var(--bg-2);
  color: var(--text-1);
}
@media (max-width: 480px) {
  .fullscreen-btn { top: 60px; /* offset clear from mobile header/notifs */ }
}

/* ── Logout Button ───────────────────────────────────────────────── */
.logout-btn {
  position: fixed;
  bottom: 84px;
  left: 16px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: rgba(20, 20, 20, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  color: var(--text-3);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.logout-btn:hover {
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.2);
  background: rgba(30, 10, 10, 0.9);
}
.logout-label {
  pointer-events: none;
}

@media (min-width: 768px) {
  .logout-btn {
    bottom: 24px;
    left: 16px;
  }
}
