:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d1117;
  color: #eef2ff;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 18% 0%, rgba(46, 213, 189, 0.16), transparent 20rem),
    linear-gradient(180deg, #0d1117 0%, #101827 56%, #0b1020 100%);
}

body[data-theme="light"] {
  background:
    radial-gradient(circle at 18% 0%, rgba(20, 184, 166, 0.20), transparent 20rem),
    linear-gradient(180deg, #f8fafc 0%, #eef6f6 58%, #e9eef7 100%);
  color: #0f172a;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

button:active {
  transform: translateY(1px);
}

.app {
  width: min(100%, 720px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(72px, calc(var(--tg-content-safe-area-inset-top, 0px) + 56px))
    max(14px, var(--tg-content-safe-area-inset-right, 0px))
    max(98px, calc(var(--tg-content-safe-area-inset-bottom, 0px) + 86px))
    max(14px, var(--tg-content-safe-area-inset-left, 0px));
}

.browser-gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: min(100%, 460px);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  padding: 28px;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.gate-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin-bottom: 18px;
  border-radius: 14px;
  background: rgba(45, 212, 191, 0.14);
  color: #5eead4;
  font-size: 30px;
}

.gate-card h1 {
  margin-bottom: 12px;
}

.gate-card p:not(.eyebrow) {
  color: #cbd5e1;
  font-size: 16px;
  line-height: 1.55;
}

.gate-card a {
  display: inline-grid;
  place-items: center;
  min-height: 50px;
  margin-top: 22px;
  border-radius: 8px;
  padding: 0 18px;
  background: #2dd4bf;
  color: #042f2e;
  font-weight: 850;
  text-decoration: none;
}

.topbar {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #5eead4;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
  text-transform: capitalize;
}

h3 {
  font-size: 22px;
  letter-spacing: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

#calendarPanel.active {
  display: flex;
  flex-direction: column;
}

#calendarPanel.summary-bottom .summary {
  order: 3;
  margin-top: 14px;
  margin-bottom: 0;
}

#calendarPanel.summary-bottom .calendar-shell {
  order: 1;
}

#calendarPanel.summary-bottom .calendar-legend {
  order: 0;
  margin-top: 0;
  margin-bottom: 24px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary.hourly {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.setup-panel {
  display: grid;
  min-height: 54vh;
  align-items: center;
}

.setup-copy {
  color: #93a4bd;
  line-height: 1.5;
}

.setup-card button,
#finishSetupButton {
  min-height: 50px;
  border-radius: 8px;
  background: #2dd4bf;
  color: #042f2e;
  font-weight: 850;
}

.stats-monthbar {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

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

.stats-monthbar h2 {
  text-align: center;
  text-transform: capitalize;
}

.summary article,
.stats-grid article,
.calendar-shell,
.breakdown div,
.stats-list,
.settings-card {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.62);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.summary article,
.stats-grid article {
  min-width: 0;
  min-height: 82px;
  padding: 14px;
  transition: transform 160ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.summary article:active,
.stats-grid article:active {
  transform: scale(0.985);
}

.summary .work-stat,
.summary .hours-stat,
.summary .day-stat,
.summary .night-stat {
  border-color: rgba(148, 163, 184, 0.16);
}

.summary span,
.stats-grid span,
.breakdown span,
.stats-list span,
#userLabel {
  color: #93a4bd;
  font-size: 12px;
  font-weight: 750;
}

.summary strong,
.stats-grid strong {
  display: block;
  margin-top: 7px;
  color: #f8fafc;
  font-size: 20px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.calendar-shell {
  padding: 12px;
  touch-action: pan-y;
  transform-origin: center;
}

.calendar-shell.swiping {
  cursor: grabbing;
}

.calendar-shell.month-enter {
  animation: month-slide-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 12px;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(15, 23, 42, 0.42);
  color: #93a4bd;
  font-size: 12px;
  font-weight: 800;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border-radius: 3px;
  border: 1px solid rgba(148, 163, 184, 0.24);
}

.legend-swatch.day {
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.46), rgba(15, 23, 42, 0.62));
  border-color: rgba(45, 212, 191, 0.62);
}

.legend-swatch.night {
  background: linear-gradient(180deg, rgba(129, 140, 248, 0.48), rgba(15, 23, 42, 0.62));
  border-color: rgba(129, 140, 248, 0.64);
}

.legend-swatch.third {
  background: linear-gradient(180deg, rgba(244, 114, 182, 0.48), rgba(15, 23, 42, 0.62));
  border-color: rgba(244, 114, 182, 0.64);
}

.legend-swatch.off {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.42), rgba(15, 23, 42, 0.62));
  border-color: rgba(251, 191, 36, 0.62);
}

.monthbar {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin-bottom: 14px;
}

.monthbar div {
  min-width: 0;
  text-align: center;
}

.nav-button {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.12);
  color: #dbeafe;
  font-size: 32px;
  font-weight: 850;
  line-height: 1;
  transition: transform 150ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.nav-button:active {
  transform: scale(0.94);
}

.danger-icon-button {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.16);
  color: #fecaca;
  font-size: 24px;
  font-weight: 900;
}

.weekdays,
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.weekdays {
  margin-bottom: 8px;
}

.weekdays span {
  color: #64748b;
  font-size: 11px;
  font-weight: 850;
  text-align: center;
  text-transform: uppercase;
}

.day-blank,
.day-cell {
  aspect-ratio: 1 / 1;
  min-width: 0;
}

.day-cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 8px;
  padding: 0;
  background: rgba(2, 6, 23, 0.34);
  color: #dbeafe;
  overflow: hidden;
  animation: day-rise 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--day-index, 0) * 8ms);
  transition: transform 140ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.day-cell:active {
  transform: scale(0.94);
}

.day-cell.weekend:not(.has-shift) {
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.18);
}

.day-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #f8fafc;
  font-size: 16px;
  font-weight: 850;
}

.day-number.today {
  background: transparent;
  color: #ff4347;
  font-weight: 950;
  text-shadow:
    0 0 8px rgba(255, 67, 71, 0.72),
    0 0 18px rgba(255, 67, 71, 0.38);
}

.has-shift.day {
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.30), rgba(15, 23, 42, 0.62));
  border-color: rgba(45, 212, 191, 0.48);
  box-shadow: 0 10px 24px rgba(45, 212, 191, 0.08);
}

.has-shift.night {
  background: linear-gradient(180deg, rgba(129, 140, 248, 0.32), rgba(15, 23, 42, 0.62));
  border-color: rgba(129, 140, 248, 0.50);
  box-shadow: 0 10px 24px rgba(129, 140, 248, 0.08);
}

.has-shift.third {
  background: linear-gradient(180deg, rgba(244, 114, 182, 0.30), rgba(15, 23, 42, 0.62));
  border-color: rgba(244, 114, 182, 0.50);
  box-shadow: 0 10px 24px rgba(244, 114, 182, 0.08);
}

.has-shift.off {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.28), rgba(15, 23, 42, 0.62));
  border-color: rgba(251, 191, 36, 0.48);
  box-shadow: 0 10px 24px rgba(251, 191, 36, 0.08);
}

.breakdown {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.breakdown div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 12px;
}

.breakdown strong {
  grid-column: 2;
  font-size: 24px;
}

.dot {
  width: 10px;
  height: 10px;
  margin-top: 3px;
  border-radius: 50%;
}

.dot.day {
  background: #2dd4bf;
}

.dot.night {
  background: #818cf8;
}

.dot.third {
  background: #f472b6;
}

.dot.off {
  background: #fbbf24;
}

.stats-shift-card small {
  display: block;
  margin-top: 6px;
  color: #93a4bd;
  font-size: 12px;
  font-weight: 800;
}

.stats-list,
.settings-card,
.profile-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.settings-card + .settings-card {
  margin-top: 14px;
}

.shift-settings-fields {
  display: grid;
  gap: 12px;
}

.backup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.backup-actions button {
  min-height: 48px;
  border-radius: 8px;
  background: rgba(45, 212, 191, 0.12);
  color: #5eead4;
  font-weight: 850;
}

.backup-actions button:first-child {
  background: #2dd4bf;
  color: #042f2e;
}

.export-first-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 13px;
  background: rgba(45, 212, 191, 0.12);
  color: #5eead4;
  font-weight: 850;
}

.shift-setting-group {
  display: grid;
  gap: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  padding-top: 12px;
}

.shift-setting-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.shift-setting-group h3 {
  font-size: 15px;
}

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

.setting-duration {
  margin: -2px 0 2px;
  color: #5eead4;
  font-size: 13px;
  font-weight: 850;
}

.duration-hint {
  margin: -4px 0 0;
  color: #5eead4;
  font-size: 13px;
  font-weight: 850;
}

.settings-card h2 {
  margin: 0 0 2px;
  color: #f8fafc;
  font-size: 16px;
}

.profile-card {
  grid-template-columns: auto 1fr auto;
  align-items: center;
  margin-bottom: 8px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background:
    linear-gradient(135deg, rgba(45, 212, 191, 0.45), rgba(129, 140, 248, 0.36)),
    #111827;
  background-position: center;
  background-size: cover;
  color: #f8fafc;
  font-size: 24px;
  font-weight: 900;
}

.profile-card strong,
.profile-card span {
  display: block;
}

.profile-card strong {
  color: #f8fafc;
  font-size: 18px;
}

.profile-card span {
  margin-top: 3px;
  color: #93a4bd;
  font-size: 13px;
  font-weight: 750;
}

.stats-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  gap: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.stats-list div:last-child {
  border-bottom: 0;
}

.stats-list .stats-total-row {
  min-height: 48px;
}

.stats-list .stats-total-row span,
.stats-list .stats-total-row strong {
  color: #f8fafc;
  font-weight: 900;
}

.stats-list strong {
  color: #f8fafc;
  font-size: 17px;
}

label {
  display: grid;
  gap: 7px;
  color: #93a4bd;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  padding: 13px 12px;
  background: rgba(2, 6, 23, 0.42);
  color: #f8fafc;
  font-size: 16px;
  outline: 0;
}

input[type="time"] {
  padding-right: 34px;
}

input[type="time"]::-webkit-calendar-picker-indicator {
  margin-right: 6px;
}

.custom-select-trigger {
  display: none;
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  padding: 0 42px 0 12px;
  background:
    linear-gradient(45deg, transparent 50%, #94a3b8 50%) right 18px center / 7px 7px no-repeat,
    linear-gradient(135deg, #94a3b8 50%, transparent 50%) right 12px center / 7px 7px no-repeat,
    rgba(2, 6, 23, 0.42);
  color: #f8fafc;
  font-weight: 850;
  text-align: left;
}

.android-selects select {
  display: none;
}

.android-selects .custom-select-trigger {
  display: block;
}

select {
  appearance: none;
}

textarea {
  min-height: 54px;
  resize: none;
}

.switch-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.switch-row input {
  width: 52px;
  height: 30px;
  appearance: none;
  border-radius: 999px;
  padding: 0;
  background: rgba(148, 163, 184, 0.28);
}

.switch-row input::after {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  margin: 2px;
  border-radius: 50%;
  background: #f8fafc;
  transition: transform 140ms ease;
}

.switch-row input:checked {
  background: #2dd4bf;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(45, 212, 191, 0.66);
}

#saveSettings,
.dialog-actions button {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 13px;
  background: #2dd4bf;
  color: #042f2e;
  font-weight: 850;
  transition: transform 150ms ease, filter 180ms ease, opacity 180ms ease;
}

#saveSettings:active,
.dialog-actions button:active,
.home-button:active {
  transform: scale(0.97);
}

#saveSettings {
  min-width: 76px;
}

.home-button {
  grid-column: 1 / -1;
  min-height: 46px;
  margin-top: 2px;
  border-radius: 8px;
  background: rgba(45, 212, 191, 0.12);
  color: #5eead4;
  font-weight: 850;
  transition: transform 150ms ease, background 180ms ease, color 180ms ease;
}

.select-dialog {
  width: min(calc(100% - 44px), 460px);
}

.select-options {
  display: grid;
  gap: 8px;
}

.select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(2, 6, 23, 0.42);
  color: #f8fafc;
  font-weight: 850;
  text-align: left;
}

.select-option.active {
  border-color: rgba(45, 212, 191, 0.58);
  background: rgba(45, 212, 191, 0.14);
  color: #5eead4;
}

.select-option strong {
  color: #5eead4;
  font-size: 18px;
}

.bottom-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: min(100%, 720px);
  margin: 0 auto;
  padding:
    10px
    max(12px, var(--tg-content-safe-area-inset-right, 0px))
    max(22px, calc(var(--tg-content-safe-area-inset-bottom, 0px) + 10px))
    max(12px, var(--tg-content-safe-area-inset-left, 0px));
  background: rgba(8, 13, 24, 0.88);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.tab-button {
  min-width: 0;
  min-height: 52px;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  font-weight: 800;
  transition: transform 160ms ease, background 180ms ease, color 180ms ease, opacity 180ms ease;
}

.tab-button:active {
  transform: scale(0.96);
}

.tab-button span,
.tab-button strong {
  display: block;
}

.tab-button span {
  height: 20px;
  font-size: 17px;
  line-height: 20px;
}

.tab-button strong {
  margin-top: 3px;
  font-size: 11px;
}

.tab-button.active {
  background: rgba(45, 212, 191, 0.13);
  color: #5eead4;
}

.center-tab {
  min-height: 56px;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.center-tab.active {
  background: rgba(45, 212, 191, 0.20);
}

.tab-button.active {
  transform: scale(1.025);
}

dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: calc(100dvh - 132px);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  padding: 0;
  background: #111827;
  color: #f8fafc;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.56);
  animation: dialog-pop 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
  animation: backdrop-fade 160ms ease;
}

dialog form {
  display: grid;
  gap: 13px;
  padding: 18px;
  max-height: calc(100dvh - 132px);
  overflow: auto;
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
}

.dialog-tools {
  display: flex;
  gap: 8px;
}

.plain-button {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.12);
  color: #dbeafe;
  font-size: 20px;
  font-weight: 850;
  transition: transform 150ms ease, background 180ms ease, color 180ms ease;
}

.plain-button:active {
  transform: scale(0.94);
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

.type-button {
  min-width: 0;
  min-height: 68px;
  border-radius: 8px;
  padding: 0 6px;
  background: rgba(148, 163, 184, 0.14);
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 850;
  overflow-wrap: anywhere;
  transition: transform 150ms ease, opacity 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.type-button:active {
  transform: scale(0.96);
}

.type-button.day,
.type-button.active.day {
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.30), rgba(15, 23, 42, 0.62));
  border: 1px solid rgba(45, 212, 191, 0.48);
  color: #f8fafc;
}

.type-button.night,
.type-button.active.night {
  background: linear-gradient(180deg, rgba(129, 140, 248, 0.32), rgba(15, 23, 42, 0.62));
  border: 1px solid rgba(129, 140, 248, 0.50);
  color: #f8fafc;
}

.type-button.third,
.type-button.active.third {
  background: linear-gradient(180deg, rgba(244, 114, 182, 0.30), rgba(15, 23, 42, 0.62));
  border: 1px solid rgba(244, 114, 182, 0.50);
  color: #f8fafc;
}

.type-button.off,
.type-button.active.off {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.28), rgba(15, 23, 42, 0.62));
  border: 1px solid rgba(251, 191, 36, 0.48);
  color: #f8fafc;
}

.type-button:not(.active) {
  opacity: 0.64;
}

.extra-toggle {
  min-height: 42px;
  width: max-content;
  max-width: 100%;
  margin: 22px 0 12px auto;
  border-radius: 8px;
  background: transparent;
  color: #5eead4;
  font-weight: 850;
  text-align: left;
  transition: transform 150ms ease, color 180ms ease;
}

.extra-toggle:active {
  transform: translateY(1px);
}

body[data-theme="light"] .summary article,
body[data-theme="light"] .stats-grid article,
body[data-theme="light"] .calendar-shell,
body[data-theme="light"] .calendar-legend span,
body[data-theme="light"] .breakdown div,
body[data-theme="light"] .stats-list,
body[data-theme="light"] .settings-card,
body[data-theme="light"] .profile-card,
body[data-theme="light"] dialog {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(100, 116, 139, 0.30);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
}

body[data-theme="light"] h1,
body[data-theme="light"] h2,
body[data-theme="light"] h3,
body[data-theme="light"] .summary strong,
body[data-theme="light"] .stats-grid strong,
body[data-theme="light"] .stats-list strong,
body[data-theme="light"] .profile-card strong,
body[data-theme="light"] .day-number,
body[data-theme="light"] .day-view strong {
  color: #0f172a;
}

body[data-theme="light"] .day-number.today {
  color: #ff4347;
  text-shadow:
    0 0 8px rgba(255, 67, 71, 0.56),
    0 0 18px rgba(255, 67, 71, 0.30);
}

body[data-theme="light"] input,
body[data-theme="light"] select,
body[data-theme="light"] textarea,
body[data-theme="light"] .custom-select-trigger,
body[data-theme="light"] .select-option {
  background-color: #ffffff;
  border-color: rgba(148, 163, 184, 0.34);
  color: #0f172a;
}

body[data-theme="light"] .bottom-tabs {
  background: rgba(248, 250, 252, 0.86);
}

body[data-theme="light"] .day-cell {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(148, 163, 184, 0.28);
}

body[data-theme="light"] .has-shift.day,
body[data-theme="light"] .type-button.day,
body[data-theme="light"] .legend-swatch.day {
  background: linear-gradient(180deg, rgba(153, 246, 228, 0.94), rgba(240, 253, 250, 0.88));
  border-color: rgba(20, 184, 166, 0.66);
  color: #0f172a;
}

body[data-theme="light"] .has-shift.night,
body[data-theme="light"] .type-button.night,
body[data-theme="light"] .legend-swatch.night {
  background: linear-gradient(180deg, rgba(199, 210, 254, 0.96), rgba(238, 242, 255, 0.90));
  border-color: rgba(99, 102, 241, 0.58);
  color: #0f172a;
}

body[data-theme="light"] .has-shift.third,
body[data-theme="light"] .type-button.third,
body[data-theme="light"] .legend-swatch.third {
  background: linear-gradient(180deg, rgba(251, 207, 232, 0.96), rgba(253, 242, 248, 0.90));
  border-color: rgba(219, 39, 119, 0.52);
  color: #0f172a;
}

body[data-theme="light"] .has-shift.off,
body[data-theme="light"] .type-button.off,
body[data-theme="light"] .legend-swatch.off {
  background: linear-gradient(180deg, rgba(254, 240, 138, 0.94), rgba(255, 251, 235, 0.92));
  border-color: rgba(245, 158, 11, 0.62);
  color: #0f172a;
}

body[data-theme="light"] .weekend {
  border-color: rgba(245, 158, 11, 0.56);
}

body[data-theme="light"] .nav-button,
body[data-theme="light"] .plain-button {
  background: rgba(226, 232, 240, 0.88);
  color: #334155;
}

body[data-theme="light"] .danger-icon-button,
body[data-theme="light"] .danger-button {
  background: rgba(254, 226, 226, 0.94) !important;
  color: #991b1b !important;
}

body[data-theme="light"] .summary span,
body[data-theme="light"] .stats-grid span,
body[data-theme="light"] .breakdown span,
body[data-theme="light"] .stats-list span,
body[data-theme="light"] label,
body[data-theme="light"] .weekdays span,
body[data-theme="light"] .profile-card span,
body[data-theme="light"] .day-view span,
body[data-theme="light"] .stats-shift-card small {
  color: #64748b;
}

body[data-theme="light"] .setting-duration {
  color: #0f766e;
}

.extra-toggle::after {
  content: " ▾";
}

.extra-toggle.open::after {
  content: " ▴";
}

.danger-button {
  background: rgba(248, 113, 113, 0.16) !important;
  color: #fecaca !important;
}

.weekend {
  border-color: rgba(251, 191, 36, 0.44);
}

.day-view {
  display: grid;
  gap: 10px;
}

.day-view div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  gap: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.day-view span {
  color: #93a4bd;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.day-view strong {
  color: #f8fafc;
}

.day-view p {
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.5;
}

.extra-fields {
  display: none;
  gap: 13px;
  margin-top: 13px;
}

.extra-fields.open {
  display: grid;
  animation: fields-open 180ms ease both;
}

@keyframes day-rise {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes month-slide-in {
  from {
    opacity: 0.72;
    transform: translateX(var(--month-shift, 14px)) scale(0.992);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes dialog-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes backdrop-fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fields-open {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 430px) {
  .app {
    padding-top: max(64px, calc(var(--tg-content-safe-area-inset-top, 0px) + 48px));
    padding-right: 10px;
    padding-left: 10px;
  }

  h1 {
    font-size: 26px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .summary {
    gap: 8px;
  }

  .summary.hourly {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary article,
  .stats-grid article {
    padding: 11px 10px;
  }

  .summary strong,
  .stats-grid strong {
    font-size: 16px;
  }

  .calendar-shell {
    padding: 8px;
  }

  .monthbar {
    grid-template-columns: 50px 1fr 50px;
  }

  .stats-monthbar {
    grid-template-columns: 50px 1fr auto;
  }

  .nav-button,
  .plain-button {
    width: 50px;
    height: 50px;
  }

  .danger-icon-button {
    width: 50px;
    height: 50px;
  }

  .weekdays,
  .calendar {
    gap: 4px;
  }

  .day-number {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .breakdown {
    gap: 8px;
  }
}

@media (max-height: 760px) {
  dialog,
  dialog form {
    max-height: calc(100dvh - 104px);
  }

  dialog form {
    gap: 10px;
    padding: 14px;
  }

  .type-button {
    min-height: 58px;
  }

  .extra-toggle {
    margin: 14px 0 8px auto;
  }

  input,
  select,
  textarea,
  .custom-select-trigger {
    padding-top: 10px;
    padding-bottom: 10px;
  }
}

@media (min-width: 900px) {
  html,
  body {
    overflow: auto;
  }

  .app {
    width: min(100% - 240px, 980px);
    margin-left: 200px;
    height: 100vh;
    min-height: 100vh;
    padding-top: 24px;
    padding-bottom: 34px;
    overflow: visible;
  }

  .topbar {
    margin-bottom: 12px;
  }

  h1 {
    font-size: 28px;
  }

  .summary,
  .stats-grid {
    width: min(100%, 720px);
    margin-bottom: 12px;
  }

  .summary article,
  .stats-grid article {
    padding: 12px;
  }

  .summary strong,
  .stats-grid strong {
    font-size: 18px;
  }

  .calendar-shell {
    width: min(100%, 720px);
    padding: 10px;
  }

  .monthbar {
    grid-template-columns: 44px 1fr 44px;
    min-height: 44px;
    margin-bottom: 8px;
  }

  .nav-button,
  .danger-icon-button {
    width: 44px;
    height: 44px;
  }

  .weekdays,
  .calendar {
    gap: 6px;
  }

  .day-number {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .bottom-tabs {
    top: 0;
    right: auto;
    bottom: 0;
    left: 0;
    width: 176px;
    grid-template-columns: 1fr;
    align-content: center;
    padding: 18px;
    border-top: 0;
    border-right: 1px solid rgba(148, 163, 184, 0.14);
  }

  .tab-button {
    min-height: 70px;
  }
}
