:root {
  color-scheme: light dark;
  --green: #34c759;
  --green-bg: rgba(52, 199, 89, 0.12);
  --orange: #ff9500;
  --blue: #007aff;
  --blue-bg: rgba(0, 122, 255, 0.1);
  --red: #ff3b30;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #000000;
  --text-secondary: rgba(60, 60, 67, 0.6);
  --text-tertiary: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.12);
  --radius: 20px;
  --radius-sm: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --tab-height: 56px;
  --header-height: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #ffffff;
    --text-secondary: rgba(235, 235, 245, 0.6);
    --text-tertiary: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.65);
    --green-bg: rgba(52, 199, 89, 0.18);
    --blue-bg: rgba(0, 122, 255, 0.15);
  }
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  min-height: 100%;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
}

.hidden { display: none !important; }

/* Demo banner */
.demo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--green-bg);
  border-bottom: 0.5px solid var(--separator);
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
}

.demo-bar-link {
  flex-shrink: 0;
  color: #fff;
  background: var(--green);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.demo-app {
  min-height: calc(100dvh - 40px - var(--safe-top));
}

@media (min-width: 481px) {
  .demo-bar {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
  }
}

/* Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  min-height: var(--header-height);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-header h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.header-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Main */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px calc(var(--tab-height) + var(--safe-bottom) + 16px);
  -webkit-overflow-scrolling: touch;
}

.panel { display: none; }
.panel.active { display: block; }

/* Summary Cards */
.summary-card {
  background: var(--green-bg);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  margin-bottom: 20px;
}

.summary-label {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.summary-amount {
  font-size: 36px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.summary-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

/* Status Banner */
.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  margin-bottom: 20px;
}

.status-banner.green {
  background: var(--green-bg);
  color: var(--text);
}

.status-banner.blue {
  background: var(--blue-bg);
  color: var(--text);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.green { background: var(--green); }
.status-dot.blue { background: var(--blue); }

/* Buttons */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary { color: #fff; }
.btn-green { background: var(--green); }
.btn-orange { background: var(--orange); }
.btn-secondary {
  background: var(--surface);
  color: var(--blue);
  border: 1.5px solid var(--blue);
}
.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1.5px solid var(--red);
  margin-top: 16px;
}
.btn-full { width: 100%; }

/* Session List */
.session-list {
  list-style: none;
}

.session-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.session-item:active { opacity: 0.7; }

.session-date {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}

.session-times {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 15px;
  margin-bottom: 4px;
}

.time-in { color: var(--green); }
.time-out { color: var(--orange); }
.time-running { color: var(--text-secondary); }
.time-break { color: var(--blue); }

.session-breaks {
  font-size: 12px;
  color: var(--blue);
  margin-bottom: 4px;
}

.session-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; }
.empty-state p {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Settings */
.settings-group {
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.settings-group h3 {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.2px;
  padding: 16px 16px 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 0.5px solid var(--separator);
  gap: 12px;
}

.settings-row label {
  font-size: 17px;
  flex-shrink: 0;
}

.settings-footer {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 16px 16px;
  line-height: 1.4;
}

.account-email {
  font-size: 15px;
  color: var(--text-secondary);
}

.input-suffix {
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-suffix input {
  width: 100px;
  text-align: right;
  font: inherit;
  font-size: 17px;
  border: none;
  background: transparent;
  color: var(--text);
  outline: none;
}

.input-suffix span {
  color: var(--text-secondary);
  font-size: 17px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stepper-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--green);
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper output {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: center;
}

.segmented {
  display: flex;
  margin: 8px 16px 12px;
  background: var(--bg);
  border-radius: 8px;
  padding: 2px;
}

.segmented-btn {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.segmented-btn.active {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* View Switch (Übersicht: Tage / Zeiträume) */
.view-switch {
  display: flex;
  background: var(--surface);
  border-radius: 10px;
  padding: 2px;
  margin-bottom: 16px;
}

.view-btn {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  -webkit-tap-highlight-color: transparent;
}

.view-btn.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

/* Period Item */
.period-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.period-item:active { opacity: 0.7; }

.period-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.period-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-bg);
  padding: 2px 8px;
  border-radius: 10px;
}

.period-amount {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.period-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Stat Groups (Zeitraum-Detail) */
.modal-spacer {
  min-width: 76px;
}

.stat-group {
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  overflow: hidden;
}

.stat-group h3 {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.2px;
  padding: 16px 16px 8px;
}

.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 0.5px solid var(--separator);
}

.stat-label {
  font-size: 15px;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.stat-row.highlight .stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
}

/* Tab Bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--surface);
  border-top: 0.5px solid var(--separator);
  padding-bottom: var(--safe-bottom);
  z-index: 20;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab.active { color: var(--green); }
.tab svg { display: block; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}

.modal-sheet-full {
  max-height: 95dvh;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--separator);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 600;
}

.modal-cancel {
  border: none;
  background: none;
  color: var(--blue);
  font: inherit;
  font-size: 17px;
  cursor: pointer;
  padding: 4px 0;
}

.modal-confirm {
  border: none;
  background: none;
  color: var(--blue);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.modal-body {
  padding: 20px 16px;
  flex: 1;
  overflow-y: auto;
}

.modal-body-scroll {
  -webkit-overflow-scrolling: touch;
}

.modal-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 16px;
}

/* Time Picker */
.time-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.time-picker input[type="time"] {
  font: inherit;
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: none;
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
}

/* Form */
.form-section {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.form-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.4;
}

.form-error {
  color: var(--red);
  font-size: 15px;
  padding: 12px 16px;
  background: rgba(255, 59, 48, 0.1);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 17px;
  cursor: pointer;
  margin-bottom: 12px;
}

.toggle-row input { display: none; }

.toggle-switch {
  width: 51px;
  height: 31px;
  background: var(--separator);
  border-radius: 16px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.toggle-row input:checked + .toggle-switch {
  background: var(--green);
}

.toggle-row input:checked + .toggle-switch::after {
  transform: translateX(20px);
}

/* Break Item */
.break-item {
  border-top: 0.5px solid var(--separator);
  padding-top: 16px;
  margin-top: 16px;
}

.break-item:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

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

.break-header span {
  font-size: 15px;
  font-weight: 600;
}

.break-delete {
  border: none;
  background: none;
  color: var(--red);
  font-size: 15px;
  cursor: pointer;
  padding: 4px;
}

.break-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

@media (min-width: 481px) {
  body {
    background: var(--separator);
  }

  #app {
    box-shadow: 0 0 40px rgba(0,0,0,0.08);
    background: var(--bg);
  }
}

/* Login */
#login-app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
}

.login-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 24px;
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
  text-align: center;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 32px;
  line-height: 1.4;
}

.login-form {
  display: flex;
  flex-direction: column;
}

.login-form .form-section {
  margin-bottom: 14px;
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field .form-input {
  flex: 1;
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.password-toggle.active { color: var(--green); }

.login-row {
  display: flex;
  align-items: center;
  margin: 4px 0 20px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-row input { display: none; }

.checkbox-box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--separator);
  flex-shrink: 0;
  position: relative;
}

.checkbox-row input:checked + .checkbox-box {
  background: var(--green);
  border-color: var(--green);
}

.checkbox-row input:checked + .checkbox-box::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.login-submit {
  margin-top: 4px;
  padding: 16px;
  font-size: 16px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-tertiary);
  font-size: 13px;
  margin: 20px 0;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 0.5px;
  background: var(--separator);
}

.login-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  padding-top: 8px;
}

@media (min-width: 481px) {
  #login-app {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
    background: var(--bg);
    min-height: 100dvh;
  }
}
