@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,600;1,9..40,400&display=swap');

/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg: #0e0e0f;
  --bg2: #161618;
  --bg3: #1e1e21;
  --border: #2a2a2e;
  --border2: #38383e;
  --text: #f0f0f2;
  --text2: #a0a0a8;
  --text3: #606068;
  --accent: #f37021;
  --accent-dim: rgba(243, 112, 33, 0.12);
  --accent-dim2: rgba(243, 112, 33, 0.06);
  --danger: #ff5555;
  --danger-dim: rgba(255, 85, 85, 0.12);
  --success: #f37021;
  --success-dim: rgba(243, 112, 33, 0.1);
  --warning: #ffb86c;
  --warning-dim: rgba(255, 184, 108, 0.1);
  --info: #8be9fd;
  --radius: 12px;
  --radius-sm: 8px;
  --font-mono: 'Space Mono', monospace;
  --font-sans: 'DM Sans', sans-serif;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Auth Screen ────────────────────────────────────────────────────────── */
#auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

#auth-screen::before {
  content: '';
  position: absolute;
  top: -40%;
  left: -40%;
  width: 80%;
  height: 80%;
  background: radial-gradient(ellipse, rgba(243, 112, 33, 0.05) 0%, transparent 70%);
  pointer-events: none;
}

.auth-logo {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.auth-title {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 40px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
}

.auth-tab.active {
  background: var(--accent);
  color: var(--bg);
}

/* ─── Form Elements ──────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 7px;
}

input[type="text"],
input[type="password"],
input[type="time"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

input[type="time"] {
  font-size: 18px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--bg2);
}

input::placeholder { color: var(--text3); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  width: 100%;
  padding: 14px;
  font-size: 14px;
}

.btn-primary:hover, .btn-primary:active { opacity: 0.88; transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border2);
}

.btn-ghost:hover { border-color: var(--border2); background: var(--bg3); color: var(--text); }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(255,85,85,0.2);
}

.btn-danger:hover { background: rgba(255,85,85,0.2); }

.btn-sm { padding: 7px 12px; font-size: 11px; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon:hover { background: var(--bg2); color: var(--text); border-color: var(--border2); }

/* ─── App Layout ─────────────────────────────────────────────────────────── */
#app-screen {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 80px;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14, 14, 15, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  flex-direction: column;
}

.header-logo {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-transform: uppercase;
  line-height: 1;
}

.header-user {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* ─── Week Navigation ────────────────────────────────────────────────────── */
.week-nav {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.week-label {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  flex: 1;
}

.week-badge {
  font-size: 10px;
  font-weight: 400;
  color: var(--text3);
  display: block;
  margin-top: 1px;
}

/* ─── Weekly Summary Card ────────────────────────────────────────────────── */
.summary-card {
  margin: 0 16px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
}

.summary-card.complete::before { background: var(--success); }
.summary-card.over-time::before { background: var(--warning); }

.summary-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.summary-main {
  display: flex;
  flex-direction: column;
}

.summary-hours {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.summary-hours span {
  font-size: 14px;
  color: var(--text2);
  font-weight: 400;
}

.summary-label {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-remaining {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(243, 112, 33, 0.2);
}

.badge-done {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid rgba(243, 112, 33, 0.2);
}

.badge-warning {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid rgba(255, 184, 108, 0.2);
}

/* Progress bar */
.progress-bar {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.complete { background: var(--success); }
.progress-fill.over-time { background: var(--warning); }

.summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-item {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Days List ──────────────────────────────────────────────────────────── */
.days-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}

.day-card.today {
  border-color: var(--accent);
}

.day-card.active {
  border-color: var(--border2);
}

.day-card-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.day-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.day-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border2);
  flex-shrink: 0;
}

.day-dot.worked { background: var(--success); }
.day-dot.partial { background: var(--warning); }
.day-dot.today-dot { background: var(--accent); }

.day-name-wrap {
  display: flex;
  flex-direction: column;
}

.day-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.day-date {
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
}

.day-hours {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.day-hours-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.day-hours-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.day-chevron {
  font-size: 12px;
  color: var(--text3);
  transition: transform var(--transition);
  margin-left: 8px;
}

.day-card.active .day-chevron { transform: rotate(180deg); }

/* Day form */
.day-form {
  border-top: 1px solid var(--border);
  padding: 16px;
  display: none;
}

.day-card.active .day-form { display: block; }

.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.time-field {
  display: flex;
  flex-direction: column;
}

.time-field label {
  font-size: 10px;
  margin-bottom: 5px;
}

/* Breaks */
.breaks-section {
  margin-bottom: 14px;
}

.breaks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.breaks-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
}

.break-item {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.break-item .time-field label { display: none; }
.break-item .time-field:first-child label { display: block; font-size: 9px; }

.day-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.day-form-actions .btn-primary {
  flex: 1;
}

/* Day summary inline */
.day-result {
  background: var(--accent-dim2);
  border: 1px solid rgba(243, 112, 33, 0.1);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.day-result-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
}

.day-result-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

/* ─── Bottom Nav ─────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(22, 22, 24, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  gap: 4px;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text3);
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim2);
}

.nav-icon { font-size: 20px; line-height: 1; }

.nav-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Settings View ──────────────────────────────────────────────────────── */
.settings-section {
  padding: 16px;
}

.settings-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.settings-row-label {
  font-size: 14px;
  color: var(--text);
  flex: 1;
}

.settings-row-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.settings-row input {
  width: 90px;
  text-align: center;
  font-size: 16px;
  padding: 10px;
  flex-shrink: 0;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  z-index: 1000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toastIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  width: 100%;
  font-family: var(--font-mono);
}

.toast.success { border-color: rgba(243, 112, 33, 0.3); color: var(--success); }
.toast.error { border-color: rgba(255, 85, 85, 0.3); color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Loading ────────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 10px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--text3);
}

.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-title { font-family: var(--font-mono); font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.empty-sub { font-size: 12px; }

/* ─── History View ───────────────────────────────────────────────────────── */
.history-header {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-select {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 10px 14px;
}

.history-total {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 16px 16px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-total-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.history-total-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

.error-message {
  color: var(--danger);
  font-size: 12px;
  font-family: var(--font-mono);
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--danger-dim);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 85, 85, 0.2);
}

/* ─── Views ──────────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: flex; flex-direction: column; flex: 1; }
