:root {
  --blue: #0e5c99;
  --blue-dark: #0a3f6b;
  --blue-soft: #e7f2fb;
  --sand: #f4e6c8;
  --sand-deep: #e4c98a;
  --paper: #fbf7f0;
  --card: #ffffff;
  --ink: #1a2b3a;
  --muted: #5c6d7e;
  --line: #eadfcd;
  --urgent: #c0392b;
  --urgent-bg: #fdecea;
  --priority: #e07a12;
  --priority-bg: #fff4e5;
  --normal: #1f7a4d;
  --normal-bg: #e8f6ee;
  --checkin: #1f7a4d;
  --checkout: #0e5c99;
  --changeover: #8a3e86;
  --block: #8a6a32;
  --shadow: 0 10px 30px rgba(20, 48, 72, 0.08);
  --radius: 18px;
  --nav: 72px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #fff 0%, transparent 50%),
    linear-gradient(180deg, #f7edd8 0%, #e7f0f8 100%);
  min-height: 100vh;
  line-height: 1.4;
}
button, input, select { font: inherit; color: inherit; }
button { touch-action: manipulation; }
a { color: var(--blue-dark); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(14, 92, 153, 0.06);
  padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  background: var(--blue);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand strong { display: block; font-size: 1.05rem; letter-spacing: 0.01em; }
.brand small { display: block; opacity: 0.85; font-size: 0.78rem; }
.sun { display: grid; place-items: center; background: rgba(255,255,255,0.12); border-radius: 50%; padding: 4px; }
.lang-top { display: flex; align-items: center; gap: 6px; }
.lang-top select {
  min-height: 44px; border-radius: 12px; border: 0; padding: 0 10px;
  background: #fff; color: var(--ink); font-weight: 700;
}
.lang-go {
  min-height: 44px; min-width: 44px; border: 0; border-radius: 12px;
  background: var(--sand); color: var(--blue-dark); font-weight: 800;
}

.syncbar {
  padding: 8px 14px; font-size: 0.86rem; background: var(--sand); color: var(--blue-dark); font-weight: 650;
}
.syncbar.is-stale { background: #ffe8c2; }
.syncbar.is-error { background: var(--urgent-bg); color: var(--urgent); }
.syncbar.is-waiting { background: #efe7d8; color: var(--muted); }

.toolbar { padding: 12px 14px 0; display: grid; gap: 10px; }
.cleaner-field, .filters label { display: grid; gap: 4px; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
input[type="text"], input[type="password"], input[type="date"] {
  width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; padding: 0 12px; font-size: 16px;
}
.filters { display: flex; align-items: end; gap: 10px; }
.filters label { flex: 1; }
.text-link { min-height: 48px; display: grid; place-items: center; font-weight: 700; font-size: 0.9rem; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg a {
  min-height: 46px; display: grid; place-items: center; text-decoration: none;
  border-radius: 12px; background: #fff; border: 1px solid var(--line); font-weight: 750; color: var(--ink);
}
.seg a.is-on { background: var(--blue); color: #fff; border-color: var(--blue); }
.hint { margin: 4px 0 8px; color: var(--muted); font-size: 0.86rem; }
.banner {
  margin: 12px 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--urgent-bg); color: var(--urgent); font-weight: 700;
}
.banner-inline { margin: 0 0 8px; }

.section { padding: 6px 14px 8px; }
.section h2, .day-block h3, .day-panel h3 {
  display: flex; align-items: baseline; gap: 8px;
  margin: 14px 0 8px; font-size: 1.15rem;
}
.section h2 span, .day-panel h3 .hint { color: var(--muted); font-weight: 650; font-size: 0.85rem; }
.section h2 {
  position: sticky; top: 58px; z-index: 8;
  background: linear-gradient(var(--paper) 70%, transparent); padding: 8px 0;
}
.history { margin-top: 8px; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 14px 14px 12px;
  margin: 0 0 12px; box-shadow: var(--shadow); border-left: 7px solid var(--normal);
}
.card.is-urgent { border-left-color: var(--urgent); }
.card.is-priority { border-left-color: var(--priority); }
.card.is-block { background: linear-gradient(180deg, #fffdf8, #fff); }
.card.is-dismissed, .card.is-done { opacity: 0.92; }
.card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card h3 { margin: 0; font-size: 1.45rem; letter-spacing: -0.02em; line-height: 1.1; }
.full-name, .date-line { margin: 0 0 2px; color: var(--muted); font-size: 0.86rem; }
.date-line { font-weight: 700; }
.badge-late {
  display: inline-block; margin-right: 6px; padding: 2px 7px; border-radius: 999px;
  background: var(--urgent); color: #fff; font-size: 0.72rem; letter-spacing: 0.02em;
}
.pill {
  flex: none; border-radius: 999px; padding: 6px 10px; font-size: 0.75rem; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.pill-urgent { background: var(--urgent); color: #fff; }
.pill-priority { background: var(--priority); color: #fff; }
.pill-normal { background: var(--normal-bg); color: var(--normal); }
.pill-manual { background: #e6f6f4; color: #0f766e; }
.badges { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.option-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.option-list li { background: var(--sand); color: var(--blue-dark); border-radius: 999px; padding: 4px 10px; font-size: 0.82rem; font-weight: 750; }
.notes { margin: 0 0 8px; color: var(--ink); }
.manual-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.btn-edit, .btn-delete {
  min-height: 48px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; text-decoration: none;
}
.btn-edit { background: var(--blue-soft); color: var(--blue-dark); }
.btn-delete { width: 100%; border: 1.5px solid #e7c4c0; background: #fff; color: var(--urgent); }
.manual-page { padding: 16px 14px 24px; }
.manual-page h1 { margin: 8px 0 4px; font-size: 1.6rem; }
.manual-form, .delete-form { display: grid; gap: 8px; }
.manual-form label, .manual-form legend { font-weight: 750; }
.manual-form select, .manual-form textarea {
  width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 10px 12px; font-size: 16px;
}
.manual-form fieldset { border: 0; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 48px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-weight: 700; }
.choice input { width: 22px; height: 22px; }
.dot-manual { background: #0f766e; }
.is-manual .tag { background: #0f766e; }
.times { margin: 10px 0 6px; font-size: 0.98rem; display: grid; gap: 2px; }
.times strong { font-size: 1.05rem; }
.sep { display: none; }
.kind-line, .block-title { margin: 0 0 8px; font-weight: 700; }
.block-title { color: var(--block); }
.who { margin: 8px 0 0; color: var(--muted); font-size: 0.9rem; }

.states { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.state {
  min-height: 54px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff;
  font-weight: 800; font-size: 0.82rem; line-height: 1.15; padding: 6px;
}
.state.is-on { color: #fff; }
.state-pending.is-on { background: var(--blue); border-color: var(--blue); }
.state-in_progress.is-on { background: var(--priority); border-color: var(--priority); }
.state-done.is-on { background: var(--normal); border-color: var(--normal); }
.btn-dismiss, .btn-undo, .btn-primary {
  width: 100%; min-height: 52px; border-radius: 14px; border: 0; font-weight: 800; margin-top: 8px;
}
.btn-dismiss { background: var(--sand); color: var(--blue-dark); }
.btn-undo { background: #fff; border: 1.5px solid var(--line); }
.btn-primary { background: var(--blue); color: #fff; font-size: 1.05rem; }
.text-button {
  background: none; border: 0; color: var(--muted); min-height: 48px; font-weight: 700; padding: 0 8px;
}
.signout { display: flex; justify-content: center; padding-bottom: 12px; }
.empty { margin: 12px 14px; padding: 18px; border-radius: 14px; background: #fff; color: var(--muted); text-align: center; }
.older { margin: 0 14px 12px; background: #fff; border-radius: 14px; padding: 8px 12px; }
.older summary { min-height: 48px; display: flex; align-items: center; font-weight: 800; cursor: pointer; }

.bottom-nav {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  width: min(760px, 100%); bottom: 0;
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-weight: 750; font-size: 0.82rem;
}
.bottom-nav a.is-on { color: var(--blue); }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
}
.login-card {
  width: min(420px, 100%); background: #fff; border-radius: 28px; padding: 28px 22px 18px;
  box-shadow: var(--shadow);
}
.login-brand { text-align: center; }
.sun-lg { display: inline-grid; }
.eyebrow { margin: 8px 0 0; letter-spacing: 0.14em; text-transform: uppercase; color: var(--blue); font-weight: 800; font-size: 0.78rem; }
.login-card h1 { margin: 4px 0; font-size: 2rem; }
.lede { margin: 0 0 16px; color: var(--muted); }
.login-form { display: grid; gap: 6px; }
.login-form label { font-weight: 750; font-size: 0.9rem; margin-top: 8px; }
.lang-form { margin-top: 18px; }
.lang-label { margin: 0 0 8px; font-weight: 800; color: var(--muted); font-size: 0.86rem; }
.lang-pick { display: grid; gap: 8px; }
.lang-pick button {
  min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 750;
}
.lang-pick button.is-on { background: var(--blue); color: #fff; border-color: var(--blue); }
.fine-print { text-align: center; color: var(--muted); font-size: 0.8rem; }
.login-card .banner { margin: 0 0 12px; }

.calendar-intro { margin: 12px 14px 0; color: var(--muted); }
.year-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px 0; }
.year-bar strong { font-size: 1.3rem; }
.icon-btn {
  min-width: 48px; min-height: 48px; display: grid; place-items: center;
  text-decoration: none; font-size: 1.8rem; font-weight: 700; color: var(--blue);
}
.months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 14px 8px; }
.month-chip {
  min-height: 52px; border-radius: 12px; background: #fff; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: 1px solid var(--line); font-weight: 800; font-size: 0.82rem; overflow: hidden;
}
.month-chip small { font-weight: 700; color: var(--muted); font-size: 0.68rem; line-height: 1; }
.month-chip.is-on { background: var(--blue); color: #fff; border-color: var(--blue); }
.month-chip.is-on small { color: #fff; }
.month-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 0 14px; }
.month-nav h2 { margin: 0; font-size: 1.15rem; text-align: center; }
.month-nav a { font-weight: 750; font-size: 0.82rem; min-height: 44px; display: grid; align-items: center; }
.month-nav a:last-child { text-align: right; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; list-style: none; padding: 8px 14px; margin: 0; font-size: 0.82rem; font-weight: 700; }
.legend li { display: flex; align-items: center; gap: 6px; }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 0 10px; }
.weekdays span { text-align: center; font-size: 0.72rem; font-weight: 800; color: var(--muted); }
.cell {
  min-height: 52px; border-radius: 10px; background: #fff; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 1px solid transparent;
}
.cell.is-out { background: transparent; }
.cell.is-today { box-shadow: inset 0 0 0 2px var(--blue); }
.cell.is-selected { background: var(--blue-soft); }
.num { font-weight: 800; font-size: 0.92rem; }
.dots { display: flex; gap: 3px; min-height: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-in { background: var(--checkin); }
.dot-out { background: var(--checkout); }
.dot-both { background: var(--changeover); }
.dot-block { background: var(--block); }
.day-panel, .day-block { padding: 0 14px 8px; }
.agenda { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cal-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  background: #fff; border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow);
}
.tag {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em; border-radius: 999px; padding: 6px 8px;
  color: #fff; text-align: center; max-width: 9.2rem;
}
.is-checkin .tag { background: var(--checkin); }
.is-checkout .tag { background: var(--checkout); }
.is-changeover .tag { background: var(--changeover); }
.is-block .tag { background: var(--block); }
.who { display: flex; flex-direction: column; min-width: 0; }
.who strong { font-size: 1rem; }
.who small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-times { font-weight: 800; font-size: 0.82rem; color: var(--ink); text-align: right; }
.message-page { padding: 32px 16px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav) + 12px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 50;
  width: min(420px, calc(100% - 24px)); text-align: center; font-weight: 700;
}
@media (max-width: 380px) {
  .state { font-size: 0.75rem; }
  .card h3 { font-size: 1.28rem; }
}
@media (min-width: 720px) {
  .months { grid-template-columns: repeat(6, 1fr); }
}
@media (min-width: 800px) {
  body { padding: 18px 0 28px; }
  .app-shell { border-radius: 24px; min-height: calc(100vh - 46px); overflow: clip; }
  .bottom-nav { border-radius: 0 0 24px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
