/* ========== RESET & BASE ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #f5f5f0;
  --surface: #ffffff;
  --surface-secondary: #f0efeb;
  --surface-elevated: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-tertiary: #a0a0a0;
  --label: #1a1a1a;
  --accent: #e85d3a;
  --accent-light: rgba(232,93,58,0.08);
  --accent-glow: rgba(232,93,58,0.2);
  --green: #2ecc71;
  --green-bg: rgba(46,204,113,0.12);
  --red: #e74c3c;
  --red-bg: rgba(231,76,60,0.08);
  --orange: #f39c12;
  --orange-bg: rgba(243,156,18,0.12);
  --border: rgba(0,0,0,0.06);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.03), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.08);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.04), 0 0 1px rgba(0,0,0,0.06);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--safe-bottom) + 32px);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ========== NAV ========== */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
}

.nav-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--text);
}

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

.nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.nav-btn:active {
  transform: scale(0.9);
  background: var(--surface-secondary);
}

/* ========== SUMMARY CARD ========== */
.summary-card {
  background: linear-gradient(145deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
  color: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  margin-bottom: 28px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(232,93,58,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.summary-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.45;
  margin-bottom: 8px;
}

.summary-amount {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin-bottom: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #d4d4d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.summary-gross {
  font-size: 0.82rem;
  opacity: 0.4;
  font-weight: 400;
}

/* ========== WEEK SECTIONS ========== */
.week-section {
  margin-bottom: 28px;
}

.week-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 2px;
}

.week-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.week-hours {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 600;
  background: var(--surface);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.shifts-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ========== SHIFT CARD ========== */
.shift-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.shift-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shift-selects {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.shift-selects select {
  flex: 1;
  min-width: 0;
  padding: 9px 6px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border);
  background: var(--surface-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all 0.15s ease;
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%23a0a0a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  padding-right: 20px;
}

.shift-selects select:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.block-selects {
  flex-wrap: nowrap;
  align-items: flex-end;
}

.block-selects select,
.block-field {
  flex: 1;
  min-width: 0;
}

.block-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.block-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.block-start,
.block-duration {
  width: 100%;
  padding: 9px 6px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border);
  background: var(--surface-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s ease;
  text-align: center;
}

.block-start:focus,
.block-duration:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.shift-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
}

.no-diff-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.no-diff-check {
  width: 14px;
  height: 14px;
  accent-color: var(--orange);
  cursor: pointer;
}

.timeblock-card {
  border-left: 3px solid var(--orange);
}

.btn-add-block {
  background: var(--orange-bg);
  color: var(--orange);
}

.shift-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 2px;
  line-height: 1;
  border-radius: 6px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.shift-remove:active {
  background: var(--red-bg);
  color: var(--red);
}

.shift-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  min-height: 26px;
}

.shift-time-range {
  font-size: 0.73rem;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.shift-bonus {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--green);
  background: var(--green-bg);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.shift-bonus:empty {
  display: none;
}

.shift-bonus.ot {
  color: var(--orange);
  background: var(--orange-bg);
}

/* ========== ADD SHIFT BTN ========== */
.btn-add,
.btn-add-block {
  width: 100%;
  padding: 13px;
  border: 2px dashed rgba(0,0,0,0.07);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  margin-top: 10px;
  transition: all 0.2s ease;
}

.btn-add:active,
.btn-add-block:active {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* ========== BREAKDOWN ========== */
.breakdown-section {
  margin-bottom: 32px;
}

.breakdown-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all 0.2s ease;
}

.breakdown-toggle:active {
  transform: scale(0.99);
}

.chevron {
  transition: transform 0.3s ease;
  color: var(--text-tertiary);
}

.breakdown-toggle.open .chevron {
  transform: rotate(180deg);
}

.breakdown-toggle.open {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.breakdown-body {
  background: var(--surface);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border: 1px solid var(--border);
  border-top: none;
  overflow: hidden;
}

.breakdown-body.hidden {
  display: none;
}

.breakdown-group {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}

.breakdown-group h3 {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 10px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 0.84rem;
  gap: 8px;
}

.breakdown-row span:first-child {
  flex: 1;
  color: var(--text-secondary);
  font-weight: 400;
}

.breakdown-row span:last-child {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.breakdown-row.total {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 10px;
  font-weight: 700;
}

.breakdown-row.total span:first-child {
  color: var(--text);
  font-weight: 700;
}

.breakdown-row.net-total {
  font-size: 1.15rem;
  font-weight: 800;
  padding: 6px 0;
}

.breakdown-row.net-total span:first-child {
  color: var(--text);
}

.breakdown-row.net-total span:last-child {
  color: var(--green);
}

/* ========== SETTINGS PANEL ========== */
.panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--safe-top) 20px calc(var(--safe-bottom) + 32px);
  animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.panel.hidden {
  display: none;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 20px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.panel-header h2 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.close-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.panel-body {
  max-width: 480px;
  margin: 0 auto;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 28px 0 14px;
}

.per-period {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-tertiary);
}

.input-group {
  margin-bottom: 14px;
}

.input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--label);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  transition: all 0.15s ease;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.input-group input::placeholder {
  color: var(--text-tertiary);
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  min-width: 0;
}

.inline-select {
  padding: 13px 10px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%23a0a0a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.inline-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 32px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(232,93,58,0.3);
  letter-spacing: -0.01em;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 28px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1a1a1a;
  color: #fff;
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 999;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ========== RESPONSIVE ========== */
@media (min-width: 500px) {
  .shift-selects select {
    font-size: 0.82rem;
    padding: 10px 8px;
  }
}

/* ========== THEME TOGGLE ICONS ========== */
[data-theme="light"] .icon-sun,
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-moon,
[data-theme="dark"] .icon-sun { display: block; }

/* ========== DARK MODE ========== */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #1a1a1a;
  --surface-secondary: #242424;
  --surface-elevated: #1e1e1e;
  --text: #f0f0f0;
  --text-secondary: #888888;
  --text-tertiary: #555555;
  --label: #f0f0f0;
  --border: rgba(255,255,255,0.07);
  --accent-light: rgba(232,93,58,0.12);
  --accent-glow: rgba(232,93,58,0.25);
  --green-bg: rgba(46,204,113,0.15);
  --orange-bg: rgba(243,156,18,0.15);
  --red-bg: rgba(231,76,60,0.12);
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --shadow-card: 0 0 0 1px rgba(255,255,255,0.04);
}

[data-theme="dark"] .summary-card {
  background: linear-gradient(145deg, #1a1a1a 0%, #2a2a2a 50%, #1a1a1a 100%);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

[data-theme="dark"] .shift-selects select {
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%23555' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

[data-theme="dark"] .week-hours {
  background: var(--surface-secondary);
}

[data-theme="dark"] .btn-add,
[data-theme="dark"] .btn-add-block {
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .toast {
  background: #2a2a2a;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
