:root {
  color-scheme: light;
  --brand: #009fe4;
  --brand-dark: #0078ad;
  --brand-soft: #e4f6fd;
  --accent: #009fe4;
  --ink: #393939;
  --muted: #68747a;
  --bg: #f4f7f9;
  --surface: #ffffff;
  --line: #d8e4e9;
  --success: #207a55;
  --danger: #b83b3b;
  --warning: #8a6113;
  --shadow: 0 14px 40px rgba(0, 91, 132, .12);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(28px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 12% 5%, rgba(0, 159, 228, .20), transparent 31%),
    linear-gradient(155deg, #e8f7fd 0%, #ffffff 55%, #e4f4fa 100%);
}

.auth-card {
  width: min(100%, 470px);
  padding: 34px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 30px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand-logo { display: block; width: 310px; max-width: 100%; height: auto; margin-bottom: 22px; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 8vw, 2.8rem); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 1.25rem; letter-spacing: -.02em; }
.eyebrow { margin-bottom: 5px; color: var(--brand); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.subline, .muted { color: var(--muted); }
.subline { margin-bottom: 26px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 22px 0; padding: 4px; border-radius: 14px; background: #edf3f4; }
.segment { min-height: 44px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-weight: 750; }
.segment.active { color: var(--brand-dark); background: white; box-shadow: 0 3px 10px rgba(0,94,137,.09); }

.stack { display: grid; gap: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 7px; color: var(--ink); font-size: .86rem; font-weight: 700; }
small, .fineprint { color: var(--muted); font-size: .75rem; font-weight: 500; line-height: 1.5; }
input, select {
  width: 100%; min-height: 49px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 13px;
  color: var(--ink); background: white; outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,159,228,.15); }

.primary, .secondary, .danger, .vacation-button, .text-button {
  min-height: 47px; padding: 11px 16px; border-radius: 13px; font-weight: 800;
}
.primary { border: 1px solid var(--brand); color: white; background: var(--brand); box-shadow: 0 8px 18px rgba(0,159,228,.22); }
.primary:hover { background: var(--brand-dark); }
.secondary { border: 1px solid var(--line); color: var(--brand-dark); background: white; }
.secondary:hover { border-color: var(--brand); background: var(--brand-soft); }
.danger { border: 1px solid #ebc8c8; color: var(--danger); background: #fff6f6; }
.full { width: 100%; }
.compact { min-height: 38px; padding: 7px 11px; font-size: .82rem; }
.offline-hint { margin: 18px 0 10px; padding: 12px; border-radius: 12px; color: #075b82; background: var(--brand-soft); font-size: .84rem; line-height: 1.45; }
.optional { color: var(--muted); font-size: .72rem; font-weight: 600; }

.app-shell { min-height: 100vh; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; z-index: 20; top: 0;
  display: flex; align-items: center; justify-content: space-between;
  min-height: calc(82px + env(safe-area-inset-top));
  padding: calc(16px + env(safe-area-inset-top)) clamp(18px, 4vw, 36px) 15px;
  border-bottom: 1px solid rgba(216,228,233,.9);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(16px);
}
.topbar h1 { margin: 0; font-size: 1.65rem; }
.topbar-brand { display: flex; align-items: center; gap: clamp(12px, 2.5vw, 24px); min-width: 0; }
.topbar-logo { display: block; width: clamp(104px, 18vw, 145px); max-width: 100%; height: auto; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.status-badge { padding: 7px 10px; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.status-badge.online { color: #176544; background: #dff3e9; }
.status-badge.offline { color: #8a6113; background: #fff0c8; }
.icon-button { width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: white; font-size: 1.45rem; line-height: 1; }

.content { width: min(100%, 920px); margin: 0 auto; padding: 20px clamp(14px, 3vw, 28px) 30px; }
.view { display: none; animation: enter .22s ease; }
.view.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } }

.hero-card {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: clamp(22px, 5vw, 36px); border-radius: 28px;
  color: white; background: linear-gradient(135deg, #006b9b, var(--brand));
  box-shadow: 0 20px 38px rgba(0,105,151,.22);
}
.hero-card .muted { color: rgba(255,255,255,.72); }
.timer-status { margin-bottom: 8px; color: rgba(255,255,255,.8); font-weight: 650; }
.timer { font-variant-numeric: tabular-nums; font-size: clamp(2.35rem, 10vw, 4.4rem); font-weight: 850; letter-spacing: -.06em; }
.timer-button {
  flex: 0 0 auto; width: 112px; height: 112px; display: grid; place-items: center;
  align-content: center; gap: 5px; border: 6px solid rgba(255,255,255,.18); border-radius: 50%;
  color: var(--brand-dark); background: white; font-weight: 900; box-shadow: 0 14px 30px rgba(0,0,0,.18);
}
.timer-button.stop { color: white; background: #c64747; }
.timer-button-icon { font-size: 1.45rem; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin: 15px 0; }
.summary-card, .card, .section-card, .balance-card, .day-card, .month-row {
  border: 1px solid var(--line); background: var(--surface); box-shadow: 0 8px 24px rgba(0,103,149,.06);
}
.summary-card { padding: 15px; border-radius: 17px; }
.summary-card span, .balance-card span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .73rem; font-weight: 700; }
.summary-card strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.sync-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; padding: 14px 16px; border-radius: 16px; font-size: .82rem; }
.sync-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: #93a4a8; }
.sync-dot.ok { background: var(--success); }
.sync-dot.pending { background: #d29a24; }
.text-button { min-height: auto; padding: 5px; border: 0; color: var(--brand); background: transparent; }

.section-card { margin-bottom: 15px; padding: 19px; border-radius: var(--radius); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.section-heading p { margin-bottom: 4px; }
.entry-list, .day-list, .month-list, .admin-list { display: grid; gap: 9px; }
.empty-state { padding: 24px 10px; color: var(--muted); text-align: center; }
.entry {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 14px; border-radius: 14px; background: #f5f9f9;
}
.entry-main { min-width: 0; }
.entry-time { font-size: 1.02rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.entry-meta { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.entry-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.entry-edit { min-width: 42px; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 11px; color: var(--brand); background: white; font-weight: 800; }
.entry-delete { color: var(--danger); }
.vacation-button { width: 100%; border: 1px solid #a8dcf3; color: #006895; background: #edf9fe; }

.period-nav { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 12px; margin-bottom: 14px; text-align: center; }
.period-nav p { margin-bottom: 4px; }
.balance-card { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; padding: 17px; border-radius: 18px; }
.balance-card > div { text-align: center; }
.balance-card strong { font-variant-numeric: tabular-nums; }
.positive { color: var(--success) !important; }
.negative { color: var(--danger) !important; }
.day-card { padding: 16px; border-radius: 17px; }
.day-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.day-card h3 { margin: 0; font-size: .98rem; }
.day-card .day-total { font-weight: 850; }
.day-entries { margin-top: 9px; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.vacation-label { color: #0078ad; font-weight: 800; }

.month-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.month-row { display: grid; grid-template-columns: 72px 1fr auto; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 15px; }
.month-date { color: var(--muted); font-size: .78rem; font-weight: 800; }
.month-times { font-size: .83rem; line-height: 1.45; }
.month-sum { font-weight: 850; font-variant-numeric: tabular-nums; }

.vehicle-current { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px 16px; border-radius: 15px; background: var(--brand-soft); }
.vehicle-current span { color: var(--muted); font-size: .78rem; font-weight: 750; }
.vehicle-current strong { font-size: 1.18rem; letter-spacing: .04em; text-align: right; }
.warning-note { margin-bottom: 12px; padding: 11px 13px; border: 1px solid #a8dcf3; border-radius: 12px; color: #006895; background: #edf9fe; font-size: .8rem; line-height: 1.45; }
.list-note { margin: 13px 0 0; }

.admin-row { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 10px; padding: 14px; border-radius: 15px; background: #f5f9f9; }
.admin-row strong, .admin-row span { display: block; }
.admin-row small { color: var(--muted); }

.bottom-nav {
  position: fixed; z-index: 30; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 920px); display: flex; align-items: stretch; justify-content: space-around;
  min-height: calc(70px + env(safe-area-inset-bottom)); padding: 7px 4px env(safe-area-inset-bottom);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  background: rgba(255,255,255,.96); box-shadow: 0 -12px 34px rgba(0,96,139,.11); backdrop-filter: blur(16px);
}
.nav-item { flex: 1; display: grid; place-items: center; align-content: center; gap: 3px; min-width: 0; padding: 3px 1px; border: 0; color: var(--muted); background: transparent; font-size: .59rem; font-weight: 750; }
.nav-item span { font-size: 1.18rem; }
.nav-item.active { color: var(--brand); }

.dialog { width: min(94vw, 540px); max-height: 90vh; padding: 0; border: 0; border-radius: 25px; color: var(--ink); background: transparent; box-shadow: var(--shadow); }
.wide-dialog { width: min(96vw, 820px); }
.dialog::backdrop { background: rgba(18,42,53,.55); backdrop-filter: blur(3px); }
.dialog-card { overflow: auto; max-height: 90vh; padding: 23px; border-radius: 24px; background: white; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; z-index: 100; left: 50%; top: calc(16px + env(safe-area-inset-top)); transform: translate(-50%, -16px);
  max-width: min(90vw, 520px); padding: 12px 16px; border-radius: 13px; color: white; background: var(--ink);
  opacity: 0; pointer-events: none; transition: .22s ease; box-shadow: var(--shadow); font-weight: 700; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

@media (max-width: 620px) {
  .auth-card { padding: 25px 20px; }
  .brand-logo { width: 270px; max-width: 100%; }
  .topbar { align-items: flex-start; }
  .topbar-logo { width: 94px; }
  .hero-card { align-items: stretch; flex-direction: column; }
  .timer-button { width: 100%; height: 62px; grid-auto-flow: column; border-width: 3px; border-radius: 16px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card:last-child { grid-column: 1 / -1; }
  .two-col { grid-template-columns: 1fr; }
  .month-row { grid-template-columns: 58px 1fr auto; gap: 8px; }
  .admin-row { grid-template-columns: 1fr auto; }
  .admin-row .entry-edit { width: 100%; }
  .entry { align-items: flex-start; }
  .entry-actions { flex-direction: column; }
  .entry-actions .entry-edit { min-height: 34px; padding: 5px 8px; font-size: .72rem; }
  .vehicle-current { align-items: flex-start; flex-direction: column; }
  .vehicle-current strong { text-align: left; }
  .sync-row { align-items: flex-start; }
  .nav-item { font-size: .52rem; }
}

@media (min-width: 900px) {
  .content { padding-top: 28px; }
  .hero-card { min-height: 230px; }
}

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