:root {
  --navy: #16324f;
  --navy-2: #244b70;
  --blue: #2563eb;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #17212b;
  --muted: #667585;
  --line: #dce3e9;
  --danger: #b42318;
  --success: #16794a;
  --shadow: 0 12px 36px rgba(22, 50, 79, .10);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy); color: white; padding: 24px 18px; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand strong, .brand span { display: block; }
.brand span { font-size: 12px; color: rgba(255,255,255,.65); margin-top: 2px; }
.brand-mark { width: 60px; height: 60px; border-radius: 18px; background: linear-gradient(145deg, #e9b949, #d5971f); color: var(--navy); font-weight: 800; display: grid; place-items: center; letter-spacing: -.05em; }
.small-mark { width: 42px; height: 42px; border-radius: 12px; }
.nav-list { display: grid; gap: 6px; margin-top: 24px; }
.nav-button { border: 0; background: transparent; color: rgba(255,255,255,.75); text-align: left; padding: 12px 14px; border-radius: 10px; }
.nav-button:hover, .nav-button.active { color: white; background: rgba(255,255,255,.12); }
.sidebar-footer { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.14); }
.account-email { font-size: 12px; overflow-wrap: anywhere; color: rgba(255,255,255,.72); }
.text-button { border: 0; padding: 8px 0 0; background: transparent; color: white; }
.content-shell { min-width: 0; }
.topbar { min-height: 88px; padding: 18px 28px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; position: sticky; top: 0; z-index: 15; backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 25px; }
.today-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.top-actions, .button-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.button { border: 1px solid transparent; border-radius: 10px; min-height: 40px; padding: 9px 14px; font-weight: 650; }
.button.primary { color: white; background: var(--blue); }
.button.primary:hover { background: #1d4ed8; }
.button.secondary { color: var(--navy); background: #e7eef5; border-color: #ccd9e5; }
.button.ghost { color: var(--navy); background: transparent; border-color: var(--line); }
.button.danger { color: var(--danger); background: #fff1f0; border-color: #f3c6c2; }
.button.wide { width: 100%; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.sync-indicator { font-size: 12px; color: var(--muted); max-width: 190px; text-align: right; }
.sync-indicator.ok { color: var(--success); }
.sync-indicator.error { color: var(--danger); }
main { padding: 24px 28px 100px; }
.view { display: none; }
.active-view { display: block; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 2px 8px rgba(22,50,79,.03); }
.calendar-toolbar { display: flex; justify-content: space-between; gap: 18px; padding: 14px 16px; margin-bottom: 16px; }
.filter-group { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.filter-group label { min-width: 180px; }
label { display: grid; gap: 6px; color: #435261; font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid #cfd8e1; border-radius: 9px; padding: 10px 11px; background: white; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(37,99,235,.13); border-color: var(--blue); }
textarea { resize: vertical; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.legend-item { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.legend-dot { width: 9px; height: 9px; border-radius: 99px; }
.calendar-panel { padding: 16px; overflow: hidden; }
.fc { --fc-border-color: #e1e7ec; --fc-button-bg-color: var(--navy); --fc-button-border-color: var(--navy); --fc-button-hover-bg-color: var(--navy-2); --fc-button-active-bg-color: var(--blue); }
.fc .fc-toolbar-title { font-size: 19px; }
.fc .fc-button { border-radius: 8px !important; box-shadow: none !important; }
.fc-event { border-radius: 5px; padding: 1px 3px; cursor: pointer; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2, .settings-card h2 { margin: 0 0 5px; }
.section-head p, .settings-card p { margin: 0; color: var(--muted); }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.entity-card { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 17px; box-shadow: 0 2px 8px rgba(22,50,79,.03); }
.entity-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); transition: .15s ease; }
.entity-card h3 { margin: 0 0 8px; font-size: 17px; }
.entity-meta { color: var(--muted); font-size: 13px; display: grid; gap: 5px; min-height: 48px; }
.entity-actions { display: flex; gap: 8px; margin-top: 14px; }
.project-heading { display: flex; align-items: center; gap: 9px; }
.project-color { width: 12px; height: 32px; border-radius: 99px; flex: 0 0 auto; }
.status-pill { display: inline-flex; align-items: center; border-radius: 99px; background: #eef3f7; color: #4d6072; font-size: 11px; padding: 4px 8px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.settings-card { padding: 20px; }
.status-list { margin: 20px 0 0; display: grid; gap: 10px; }
.status-list div { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); padding-top: 10px; }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; text-align: right; }
.modal { width: min(760px, calc(100vw - 28px)); max-height: 92vh; border: 0; border-radius: 18px; padding: 0; box-shadow: 0 28px 80px rgba(15,35,55,.28); }
.compact-modal { width: min(650px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(10, 25, 40, .55); backdrop-filter: blur(3px); }
.modal form { padding: 22px; overflow-y: auto; max-height: 92vh; }
.modal-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 18px; }
.modal-head h2 { margin: 1px 0 0; }
.eyebrow { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--blue); font-weight: 800; }
.icon-button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: white; font-size: 24px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.conflict-box { padding: 14px; border-radius: 11px; border: 1px solid #efb6b0; background: #fff1f0; margin-bottom: 16px; }
.conflict-box p { color: #7c2d26; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 20%, #274f75, var(--navy) 48%, #0d243a); }
.login-card { width: min(430px, 100%); padding: 34px; background: white; border-radius: 22px; box-shadow: 0 28px 90px rgba(0,0,0,.28); text-align: center; }
.login-card .brand-mark { margin: 0 auto; }
.login-card h1 { margin: 18px 0 10px; }
.login-card p { color: var(--muted); line-height: 1.5; }
.toast-container { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 9px; }
.toast { background: #17212b; color: white; border-radius: 10px; padding: 11px 14px; box-shadow: var(--shadow); max-width: 360px; }
.toast.error { background: var(--danger); }
.mobile-nav, .mobile-fab { display: none; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; min-height: 72px; }
  .topbar h1 { font-size: 20px; }
  .top-actions .sync-indicator, .top-actions #sync-button, .top-actions #new-event-button { display: none; }
  main { padding: 14px 12px 90px; }
  .calendar-toolbar { display: block; }
  .legend { justify-content: flex-start; margin-top: 10px; }
  .mobile-nav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: white; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav-button { border: 0; background: white; color: var(--muted); padding: 12px 3px; font-size: 11px; }
  .mobile-nav-button.active { color: var(--blue); font-weight: 750; }
  .mobile-fab { display: grid; place-items: center; position: fixed; z-index: 31; right: 18px; bottom: calc(64px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border: 0; border-radius: 50%; background: var(--blue); color: white; font-size: 30px; box-shadow: 0 10px 28px rgba(37,99,235,.4); }
  .calendar-panel { padding: 8px; }
  .fc .fc-toolbar { align-items: stretch; gap: 8px; flex-wrap: wrap; }
  .fc .fc-toolbar-chunk:nth-child(2) { order: -1; width: 100%; }
  .fc .fc-toolbar-title { font-size: 17px; text-align: center; }
  .filter-group label { min-width: calc(50% - 6px); flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .modal { width: 100vw; max-height: 96vh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .modal form { max-height: 96vh; padding: 18px 15px calc(20px + env(safe-area-inset-bottom)); }
  .modal-actions { position: sticky; bottom: 0; background: white; }
}

@media (max-width: 520px) {
  .today-label { display: none; }
  .calendar-toolbar { padding: 10px; }
  .filter-group { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-group label { min-width: 0; }
  .filter-group .button { grid-column: span 2; }
  .cards-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .section-head { align-items: center; }
  .section-head p { display: none; }
}

.checkbox-label { display: flex; align-items: center; gap: 9px; }
.checkbox-label input { width: 18px; height: 18px; margin: 0; }
.legal-links { font-size: 12px; }
.legal-links a { color: var(--navy); }


.google-setup { margin: 14px 0 18px; padding: 14px; border: 1px solid var(--border, #d7dce3); border-radius: 12px; }
.google-setup h3 { margin-top: 0; }
.google-setup code { display: block; padding: 9px 10px; margin: 8px 0 12px; overflow-wrap: anywhere; background: rgba(127,127,127,.08); border-radius: 8px; }
.compact-form { margin-top: 10px; }

.sync-indicator.clickable { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.sync-error-box { margin-top: 18px; border: 1px solid #efb4ad; background: #fff5f3; border-radius: 12px; padding: 14px; }
.sync-error-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:8px; }
.sync-error-box pre { white-space: pre-wrap; word-break: break-word; margin:0; font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; max-height:320px; overflow:auto; }


/* Event workflow v0.1.9 */
.event-workflow { margin: 0 0 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; }
.event-workflow-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; font-weight: 700; }
.event-workflow-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.event-workflow .button { min-height: 38px; }
.button.success { color: var(--success); background: #edf9f2; border-color: #b9e3ca; }
.button.warning { color: #8a4b08; background: #fff8e8; border-color: #efd39c; }
.event-status-badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 4px 9px; font-size: 12px; font-weight: 700; background: #e7eef5; color: var(--navy); }
.event-status-badge.done { background: #edf9f2; color: var(--success); }
.event-status-badge.cancelled { background: #fff1f0; color: var(--danger); }
.reschedule-target { border-radius: 10px; outline: 3px solid rgba(37,99,235,.14); outline-offset: 4px; }
.fc-event.event-status-done { opacity: .58; }
.fc-event.event-status-done .fc-event-title, .fc-event.event-status-done .fc-list-event-title { text-decoration: line-through; }
.fc-event.event-status-cancelled { opacity: .42; filter: grayscale(.55); }
.fc-event.event-status-cancelled .fc-event-title, .fc-event.event-status-cancelled .fc-list-event-title { text-decoration: line-through; }
@media (max-width: 700px) {
  .event-workflow-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .event-workflow-actions .button { width: 100%; }
}

/* Server password login v0.3.0 */
.login-form { display: grid; gap: 12px; margin: 18px 0 10px; }
.login-form label { display: grid; gap: 7px; text-align: left; font-size: 14px; color: var(--muted); }
.login-form input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; box-sizing: border-box; }
.error-text { color: var(--danger); }
