:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --surface2: #22263a;
  --border:   #2d3148;
  --text:     #e2e8f0;
  --muted:    #6b7280;
  --accent:   #6366f1;
  --accent-h: #818cf8;
  --green:    #22c55e;
  --yellow:   #eab308;
  --red:      #ef4444;
  --radius:   12px;
  --shadow:   0 4px 24px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Layout ─────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.app-header h1 span { color: var(--accent); }

.main { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; display: grid; gap: 1.5rem; }

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* ── User bar ───────────────────────────────────── */
.user-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.user-bar select, .user-bar input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .5rem .75rem;
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
}

.user-bar select:focus, .user-bar input:focus { border-color: var(--accent); }
.user-bar select { min-width: 160px; }
.user-bar input  { width: 180px; }

/* ── Buttons ────────────────────────────────────── */
button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: .9rem;
  padding: .5rem 1.1rem;
  transition: opacity .15s, transform .1s;
}
button:hover:not(:disabled) { opacity: .85; transform: translateY(-1px); }
button:active:not(:disabled) { transform: none; }
button:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: var(--red);      color: #fff; }
.btn-icon      { background: transparent; color: var(--muted); padding: .25rem .5rem; font-size: 1rem; }
.btn-icon:hover { color: var(--red); }

/* ── Break type buttons ─────────────────────────── */
.break-buttons { display: flex; gap: .75rem; flex-wrap: wrap; }

.btn-break {
  padding: .6rem 1.4rem;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.btn-break.short { background: #312e81; color: #a5b4fc; border: 1px solid #4338ca; }
.btn-break.lunch { background: #14532d; color: #86efac; border: 1px solid #15803d; }
.btn-break.bio   { background: #713f12; color: #fde68a; border: 1px solid #b45309; }
.btn-break:hover:not(:disabled) { filter: brightness(1.2); }

/* ── Timer card ─────────────────────────────────── */
#timer-card {
  text-align: center;
  transition: border-color .3s;
}
#timer-card.active  { border-color: var(--accent); }
#timer-card.over-limit { border-color: var(--red); }

#timer-display {
  font-size: 4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
  color: var(--text);
  margin: .5rem 0;
  transition: color .3s;
}
#timer-display.over-limit { color: var(--red); animation: pulse 1s infinite; }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .6; }
}

#timer-info {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* ── Stats grid ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.stat-item { background: var(--surface2); border-radius: 10px; padding: 1rem; }
.stat-label { font-size: .75rem; color: var(--muted); margin-bottom: .25rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; }

/* ── Table ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

thead th {
  text-align: left;
  padding: .6rem .75rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: .65rem .75rem; }

.empty { text-align: center; color: var(--muted); padding: 2rem !important; }
.over-limit { color: var(--red) !important; }

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-block;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  padding: .2rem .6rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-short { background: #312e81; color: #a5b4fc; }
.badge-lunch { background: #14532d; color: #86efac; }
.badge-bio   { background: #713f12; color: #fde68a; }

/* ── Settings ───────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.setting-item label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }
.setting-item input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .45rem .75rem;
  font-size: .95rem;
  outline: none;
}
.setting-item input:focus { border-color: var(--accent); }

/* ── Mode indicator ─────────────────────────────── */
.mode {
  font-size: .78rem;
  font-weight: 600;
  padding: .3rem .7rem;
  border-radius: 999px;
}
.mode.online  { background: #14532d; color: #86efac; }
.mode.offline { background: #422006; color: #fde68a; }

/* ── Toast ──────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1.25rem;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  transform: translateY(1rem);
  opacity: 0;
  transition: all .25s;
  z-index: 9999;
  max-width: 300px;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }
.toast.info    { border-color: var(--accent); color: var(--accent); }

/* ── Date row ───────────────────────────────────── */
.date-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.date-row input[type="date"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .45rem .75rem;
  font-size: .9rem;
  outline: none;
  color-scheme: dark;
}
.date-row input[type="date"]:focus { border-color: var(--accent); }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 600px) {
  .app-header { padding: 1rem; }
  .main { padding: 1rem; }
  #timer-display { font-size: 2.8rem; }
}
