:root {
  --paper: #f4f1ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #25231f;
  --muted: #746f66;
  --faint: #a7a097;
  --line: rgba(44, 39, 31, 0.12);
  --accent: #245c46;
  --accent-hover: #174936;
  --accent-soft: #e5eee8;
  --warning: #a45d1b;
  --warning-soft: #f8ead8;
  --danger: #a43d38;
  --danger-soft: #f8e4e2;
  --blue: #32658a;
  --blue-soft: #e5eef5;
  --shadow: 0 1px 2px rgba(32, 28, 22, .04), 0 10px 32px rgba(32, 28, 22, .06);
  --radius: 14px;
  font-family: "Avenir Next", "Segoe UI Variable", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(36, 92, 70, .24); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px; background: #ebe7de; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; padding: 0 8px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--accent); color: white; font-family: Georgia, serif; font-size: 22px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: 12px; margin-top: 1px; }
.nav-list { display: grid; gap: 6px; margin-top: 44px; }
.nav-item { min-height: 46px; border: 0; background: transparent; color: var(--muted); border-radius: 9px; padding: 0 12px; text-align: left; display: flex; align-items: center; gap: 12px; font-weight: 600; }
.nav-item span { width: 22px; color: var(--faint); font-family: ui-monospace, monospace; font-size: 11px; }
.nav-item:hover { color: var(--ink); background: rgba(255,255,255,.45); }
.nav-item.active { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 3px 8px rgba(45,40,30,.04); }
.channel-card { margin-top: auto; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,253,248,.6); font-size: 13px; }
.channel-card p { margin: 0 0 12px; font-weight: 700; }
.channel-card div { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--muted); }
.channel-card small { display: block; color: var(--faint); line-height: 1.4; margin-top: 10px; }
.account-card { margin-top: 10px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,253,248,.45); }
.account-card span, .account-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-card span { color: var(--faint); font-size: 11px; }
.account-card strong { margin-top: 4px; font-size: 12px; }
.account-card .text-button { min-height: 30px; padding: 0; margin-top: 5px; font-size: 12px; }
.channel-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.channel-dot.online { background: #2d8b5e; box-shadow: 0 0 0 3px rgba(45,139,94,.12); }
.sidebar-action { margin-top: 12px; width: 100%; }

.main-content { width: min(1480px, 100%); padding: 48px clamp(24px, 4vw, 68px) 64px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(30px, 4vw, 48px); line-height: 1.05; font-weight: 600; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-family: Georgia, "Times New Roman", serif; font-size: 24px; line-height: 1.15; font-weight: 600; letter-spacing: -.018em; }
.eyebrow { margin-bottom: 8px; color: var(--accent); font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 15px; }

.primary-button, .secondary-button { min-height: 44px; border-radius: 9px; padding: 10px 16px; border: 1px solid transparent; font-weight: 700; transition: background .16s ease, transform .16s ease, border-color .16s ease; }
.primary-button { color: white; background: var(--accent); }
.primary-button:hover { background: var(--accent-hover); transform: translateY(-1px); }
.secondary-button { color: var(--ink); background: var(--surface); border-color: var(--line); }
.secondary-button:hover { background: white; border-color: rgba(44,39,31,.22); }
.text-button { min-height: 40px; border: 0; padding: 0 6px; color: var(--accent); background: transparent; font-weight: 700; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 28px; }

.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 22px; }
.summary-item { min-height: 108px; padding: 22px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.summary-item:last-child { border-right: 0; }
.summary-item .value { font-family: Georgia, serif; font-size: 32px; line-height: 1; }
.summary-item .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.summary-item .indicator { width: 28px; height: 3px; border-radius: 3px; background: var(--accent); margin-bottom: 12px; }
.summary-item:nth-child(2) .indicator { background: var(--blue); }
.summary-item:nth-child(3) .indicator { background: #3b785b; }
.summary-item:nth-child(4) .indicator { background: var(--warning); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .8fr); gap: 22px; align-items: start; }
.right-column { display: grid; gap: 22px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-heading.compact { margin-bottom: 14px; }
.view-toggle { display: flex; gap: 4px; padding: 3px; background: var(--paper); border-radius: 9px; }
.filter-chip { min-height: 34px; border: 0; border-radius: 7px; padding: 6px 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.filter-chip.active { color: var(--ink); background: var(--surface); box-shadow: 0 1px 4px rgba(32,28,22,.08); }
.search-field { display: block; margin-bottom: 10px; }
.search-field input { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); background: var(--surface-strong); border: 1px solid var(--line); border-radius: 9px; }
.search-field input::placeholder { color: var(--faint); }

.calendar-nav { display: flex; align-items: center; gap: 6px; }
.calendar-nav-button, .calendar-today-button { min-height: 38px; border: 1px solid var(--line); background: var(--surface-strong); color: var(--ink); border-radius: 8px; font-weight: 700; }
.calendar-nav-button { width: 40px; font-size: 18px; }
.calendar-today-button { padding: 0 12px; font-size: 12px; }
.calendar-nav-button:hover, .calendar-today-button:hover { border-color: rgba(44,39,31,.24); background: white; }
.calendar-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.calendar-tools .search-field { width: min(260px, 42%); margin: 0; }
.calendar-week { display: grid; grid-template-columns: repeat(7, minmax(118px, 1fr)); gap: 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-strong); scrollbar-width: thin; }
.calendar-day { min-height: 330px; border-right: 1px solid var(--line); background: var(--surface-strong); }
.calendar-day:last-child { border-right: 0; }
.calendar-day.is-today { background: #f7faf8; }
.calendar-day-header { min-height: 72px; padding: 10px 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: baseline; column-gap: 6px; }
.calendar-day-header span { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.calendar-day-header strong { justify-self: end; font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.calendar-day-header small { grid-column: 1 / -1; color: var(--faint); font-size: 10px; text-transform: uppercase; }
.calendar-day.is-today .calendar-day-header { box-shadow: inset 0 3px 0 var(--accent); }
.calendar-day.is-today .calendar-day-header strong { color: var(--accent); }
.calendar-events { display: grid; align-content: start; gap: 8px; padding: 9px; }
.calendar-event { width: 100%; min-height: 104px; padding: 10px; border: 0; border-left: 3px solid var(--blue); border-radius: 8px; color: var(--ink); background: var(--blue-soft); text-align: left; display: grid; align-content: start; gap: 5px; transition: transform .15s ease, box-shadow .15s ease; }
.calendar-event:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(35,45,38,.10); }
.calendar-event strong { font-size: 12px; line-height: 1.3; }
.calendar-event-time { font-family: ui-monospace, monospace; font-size: 11px; font-weight: 750; }
.calendar-event-location { color: var(--muted); font-size: 10px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.calendar-event-status { justify-self: start; margin-top: 3px; padding: 3px 6px; border-radius: 999px; font-size: 9px; font-weight: 800; }
.calendar-event.status-border-ongoing { border-left-color: var(--accent); background: var(--accent-soft); }
.calendar-event.status-border-done { border-left-color: #3b785b; background: #edf4ef; }
.calendar-event.status-border-delayed { border-left-color: var(--warning); background: var(--warning-soft); }
.calendar-empty { margin: 0; padding: 12px 3px; color: var(--faint); font-size: 10px; text-align: center; }

.activity-list { display: grid; }
.activity-row { display: grid; grid-template-columns: 78px minmax(0, 1fr) auto; gap: 15px; align-items: center; padding: 17px 4px; border-bottom: 1px solid var(--line); }
.activity-row:last-child { border-bottom: 0; }
.activity-time { color: var(--ink); font-family: ui-monospace, monospace; font-size: 13px; }
.activity-date { display: block; margin-top: 5px; color: var(--faint); font-size: 11px; }
.activity-title { margin: 0 0 6px; font-size: 15px; font-weight: 750; }
.activity-meta { color: var(--muted); font-size: 12px; line-height: 1.5; }
.activity-actions { display: flex; align-items: center; gap: 8px; }
.status-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.status-planned { color: var(--blue); background: var(--blue-soft); }
.status-ongoing { color: var(--accent); background: var(--accent-soft); }
.status-done { color: #3a6b4d; background: #e6f1e9; }
.status-delayed { color: var(--warning); background: var(--warning-soft); }
.row-menu { min-width: 40px; min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 20px; }
.row-menu:hover { background: var(--paper); }

.focus-panel { background: #243e34; color: #fffdf8; border-color: transparent; }
.focus-panel .eyebrow { color: #a9d4bd; }
.focus-panel h2 { color: white; }
.focus-content { padding-top: 8px; }
.focus-date { color: #b9c9c0; font-family: ui-monospace, monospace; font-size: 12px; }
.focus-content h3 { margin: 8px 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.focus-content p { margin-bottom: 14px; color: #d9e2dc; font-size: 13px; line-height: 1.55; }
.focus-content .focus-location { padding-top: 13px; border-top: 1px solid rgba(255,255,255,.16); color: #b9c9c0; }
.compact-list { display: grid; gap: 8px; }
.compact-item { padding: 12px; border-radius: 9px; background: var(--paper); }
.compact-item strong { display: block; margin-bottom: 5px; font-size: 13px; }
.compact-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.empty-state { padding: 22px 14px; border: 1px dashed rgba(44,39,31,.18); border-radius: 10px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.5; }

#activity-dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100vh - 32px); border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--surface); box-shadow: 0 30px 100px rgba(32,28,22,.24); }
#activity-dialog::backdrop { background: rgba(31,29,25,.46); backdrop-filter: blur(2px); }
#activity-form { padding: 24px; display: grid; gap: 15px; overflow-y: auto; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.dialog-heading h2 { font-size: 30px; }
#activity-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
#activity-form input, #activity-form select, #activity-form textarea { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 320px; padding: 12px 16px; border-radius: 9px; color: white; background: var(--ink); box-shadow: var(--shadow); font-size: 13px; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hidden-by-view { display: none !important; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--paper); }
.auth-shell { width: min(100%, 440px); }
.auth-card { padding: 32px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 42px; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand small { color: var(--muted); font-size: 12px; }
.auth-copy h1 { margin-bottom: 10px; font-size: 38px; }
.auth-copy > p:last-child { color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 15px; margin-top: 24px; }
.auth-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.auth-form input { width: 100%; min-height: 48px; padding: 11px 12px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 9px; }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-submit:disabled { opacity: .65; cursor: wait; }
.auth-error { margin: 0; padding: 10px 12px; border-radius: 8px; color: var(--danger); background: var(--danger-soft); font-size: 12px; line-height: 1.45; }
.auth-note { margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; line-height: 1.5; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar { padding: 24px 13px; align-items: center; }
  .brand span:last-child, .nav-item:not(.active) > :not(span), .nav-item { font-size: 0; }
  .nav-item { width: 48px; justify-content: center; padding: 0; }
  .nav-item span { width: auto; font-size: 11px; }
  .channel-card, .account-card, .sidebar-action { display: none; }
  .workspace-grid { grid-template-columns: 1fr; }
  .right-column { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .focus-panel { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 10; top: auto; bottom: 0; left: 0; right: 0; width: 100%; height: 70px; padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); border: 0; border-top: 1px solid var(--line); flex-direction: row; background: rgba(244,241,234,.96); backdrop-filter: blur(14px); }
  .brand, .channel-card, .account-card, .sidebar-action { display: none; }
  .nav-list { width: 100%; margin: 0; display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; }
  .nav-item, .nav-item:not(.active) { width: auto; height: 48px; min-height: 48px; flex-direction: column; justify-content: center; gap: 2px; padding: 4px; font-size: 10px; }
  .nav-item span { font-size: 10px; }
  .main-content { padding: 28px 16px 100px; }
  .topbar { display: grid; }
  .topbar .primary-button { width: 100%; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .right-column { grid-template-columns: 1fr; }
  .panel { padding: 17px; }
  .panel-heading { display: grid; }
  .calendar-nav { justify-content: space-between; }
  .calendar-today-button { flex: 1; }
  .calendar-tools { display: grid; }
  .calendar-tools .search-field { width: 100%; order: -1; }
  .calendar-week { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: min(78vw, 310px); scroll-snap-type: x mandatory; overscroll-behavior-x: contain; }
  .calendar-day { min-height: 300px; scroll-snap-align: start; }
  .calendar-event { min-height: 96px; }
  .view-toggle { width: 100%; }
  .filter-chip { flex: 1; }
  .activity-row { grid-template-columns: 58px minmax(0,1fr); gap: 10px; }
  .activity-actions { grid-column: 2; justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
}

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