:root {
  color-scheme: light;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #eef1f5;
  --panel: #ffffff;
  --page: #f6f8fb;
  --field: #f8fafc;
  --field-hover: #f1f5f9;
  --blue: #1d5c96;
  --blue-soft: #e6effa;
  --blue-strong: #123f69;
  --green: #047857;
  --green-soft: #d1fae5;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --teal: #0f766e;
  --teal-soft: #ccfbf1;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.05), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.12), 0 6px 16px rgba(15, 23, 42, 0.06);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.theme-dark {
  color-scheme: dark;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --line: #2a3547;
  --line-soft: #1e293b;
  --panel: #131b29;
  --page: #0a1018;
  --field: #0e1623;
  --field-hover: #1a2436;
  --blue: #5da7e6;
  --blue-soft: rgba(93, 167, 230, 0.15);
  --blue-strong: #3b88c7;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.15);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.15);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.15);
  --teal: #5eead4;
  --teal-soft: rgba(94, 234, 212, 0.15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.5);
}

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

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  background: var(--page);
  color: var(--ink);
}

.sidebar {
  background: #111923;
  color: #f8fafc;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #c4452f;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 3px;
  flex: 0 0 auto;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
}

.brand p {
  margin: 3px 0 0;
  color: #aab5c2;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav button {
  width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #dbe3ec;
  text-align: left;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav button:hover,
.nav button.active {
  background: #1d2a38;
  border-color: #314358;
  color: #fff;
}

.nav .icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  background: #27374a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sf-save {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: #c8d3e0;
  font-size: 11px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.sf-save:hover { background: rgba(255, 255, 255, 0.08); }

.sf-save-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #65d693;
  flex-shrink: 0;
}

.sf-save.dirty .sf-save-dot { background: #f0b04b; }
.sf-save.saving .sf-save-dot { background: #5cb3ff; animation: sf-pulse 1.4s ease-in-out infinite; }
.sf-save.error .sf-save-dot { background: #ff7a73; }
.sf-save.ok .sf-save-dot { background: #65d693; }

@keyframes sf-pulse {
  50% { opacity: 0.4; }
}

.sf-theme {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: #c8d3e0;
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.sf-theme:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sf-profile {
  position: relative;
  width: 100%;
}

.sf-profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: #dbe3ec;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.sf-profile-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sf-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.sf-avatar-initials {
  background: #2d4763;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 10px;
}

.sf-profile-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sf-caret {
  font-size: 10px;
  opacity: 0.6;
}

.sf-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #1a2434;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 4px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.sf-menu-item {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: #e2e8f0;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.sf-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.event-form .event-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  padding: 4px 0;
  cursor: pointer;
}

.event-form .event-toggle input[type="checkbox"] {
  width: auto;
  min-height: 0;
  margin: 0;
}

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

.event-time-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-time-inputs {
  display: flex;
  gap: 6px;
}

.event-time-inputs input[type="date"] { flex: 1.4; }
.event-time-inputs input[type="time"] { flex: 1; }

.event-time-inputs input:disabled {
  opacity: 0.4;
  background: var(--field);
}

@media (max-width: 560px) {
  .event-time-row { grid-template-columns: 1fr; }
}

.settings-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.settings-section:last-child {
  border-bottom: 0;
}

.settings-section h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  color: var(--ink-2);
  gap: 12px;
}

.settings-row strong {
  color: var(--ink);
  font-weight: 500;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-row code {
  background: var(--field);
  border: 1px solid var(--line);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11px;
  word-break: break-all;
}

.settings-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 10px;
}

.settings-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* GCal sync status */
.gcal-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 12px;
  flex-wrap: wrap;
}

.gcal-status .gcal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gcal-status.ok {
  background: var(--green-soft);
  color: var(--green);
}
.gcal-status.ok .gcal-dot { background: var(--green); }

.gcal-status.syncing {
  background: var(--blue-soft);
  color: var(--blue);
}
.gcal-status.syncing .gcal-dot { background: var(--blue); animation: sf-pulse 1.2s ease-in-out infinite; }

.gcal-status.error {
  background: var(--red-soft);
  color: var(--red);
}
.gcal-status.error .gcal-dot { background: var(--red); }

.gcal-status.pending {
  background: var(--field);
  color: var(--muted);
  border: 1px dashed var(--line);
}
.gcal-status.pending .gcal-dot { background: var(--muted-2); }

/* Invite block + guest suggestion chips */
.invite-block .invite-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}

.guest-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.guest-suggest-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 2px;
}

.guest-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  border: 1px solid rgba(29, 92, 150, 0.25);
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
}

.guest-chip:hover {
  background: var(--blue);
  color: white;
}

.guest-chip-icon {
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}

.guest-chip-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.guest-chip-text strong {
  font-weight: 600;
  font-size: 12px;
}

.guest-chip-text span {
  font-size: 10px;
  opacity: 0.7;
}

/* Attendee response statuses */
.attendees-block {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.attendees-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.attendee-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 3px 0;
}

.attendee-email {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attendee-status {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
}

.attendee-status.ok { background: var(--green-soft); color: var(--green); }
.attendee-status.no { background: var(--red-soft); color: var(--red); }
.attendee-status.maybe { background: var(--amber-soft); color: var(--amber); }
.attendee-status.wait { background: var(--field-hover); color: var(--muted); }

/* Combobox */
.cb {
  position: relative;
  width: 100%;
}

.cb-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  min-height: 32px;
  text-align: left;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.cb-trigger:hover {
  border-color: var(--muted-2);
}

.cb.open .cb-trigger {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 92, 150, 0.15);
}

.cb-trigger.empty .cb-value {
  color: var(--muted-2);
}

.cb-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cb-caret {
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
}

.cb-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  max-height: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cb-search {
  border: 0 !important;
  border-bottom: 1px solid var(--line) !important;
  border-radius: 0 !important;
  padding: 8px 12px !important;
  font-size: 13px;
  outline: none;
  background: var(--panel) !important;
  box-shadow: none !important;
}

.cb-search:focus {
  background: var(--field) !important;
}

.cb-options {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.cb-option {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cb-option:hover {
  background: var(--field-hover);
}

.cb-option.selected {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 500;
}

.cb-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.cb-add {
  background: var(--green-soft);
  border: 0;
  border-top: 1px solid var(--line);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  cursor: pointer;
  text-align: left;
}

.cb-add:hover {
  background: var(--green);
  color: white;
}

.cb-add.subtle {
  background: transparent;
  color: var(--muted);
  font-weight: 400;
}

.cb-add.subtle:hover {
  background: var(--field-hover);
  color: var(--ink);
}

/* Follow-up task chip section */
.followup-section {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.followup-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}

.followup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.fu-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.12s;
}

.fu-chip:hover {
  background: var(--blue-soft);
  border-color: rgba(29, 92, 150, 0.3);
  color: var(--blue);
}

.fu-chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.followup-fields {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 8px;
}

@media (max-width: 560px) {
  .followup-fields { grid-template-columns: 1fr; }
}

/* Universal search */
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  justify-content: flex-start !important;
  color: var(--muted) !important;
  background: var(--field) !important;
}

.topbar-search:hover {
  background: var(--field-hover) !important;
  color: var(--ink) !important;
}

.topbar-search .ts-icon {
  font-size: 16px;
  line-height: 1;
}

.topbar-search .ts-label {
  flex: 1;
  text-align: left;
}

.topbar-search .ts-kbd {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  padding: 2px 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .topbar-search .ts-label,
  .topbar-search .ts-kbd { display: none; }
  .topbar-search { min-width: 0; }
}

.search-backdrop {
  background: rgba(15, 23, 42, 0.5);
  z-index: 1100;
}

.search-modal {
  position: fixed;
  top: 12vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, 96vw);
  max-height: 76vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1101;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.search-icon {
  color: var(--muted);
  font-size: 18px;
}

.search-input {
  flex: 1;
  border: 0 !important;
  background: transparent !important;
  font-size: 15px !important;
  padding: 4px 0 !important;
  outline: none !important;
  box-shadow: none !important;
  min-height: 0 !important;
  color: var(--ink);
}

.search-input::placeholder {
  color: var(--muted-2);
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.search-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 12px 4px;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}

.search-item:hover,
.search-item.highlighted {
  background: var(--blue-soft);
}

.search-item.highlighted {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.search-item.done .search-item-primary {
  text-decoration: line-through;
  color: var(--muted);
}

.search-type-pill {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--field);
  color: var(--muted);
  flex-shrink: 0;
  min-width: 28px;
  text-align: center;
  border: 1px solid var(--line);
}

.search-item-main {
  flex: 1;
  min-width: 0;
}

.search-item-primary {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-item-secondary {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.search-item-tertiary {
  font-size: 11px;
  color: var(--muted-2);
  flex-shrink: 0;
  margin-left: 8px;
}

.search-item.hot .search-item-tertiary { color: var(--red); }

.search-empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.search-footer {
  display: flex;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  background: var(--field);
}

.search-footer kbd {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  padding: 1px 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-right: 2px;
}

.sidebar-footer strong {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}

.sidebar-footer span {
  color: #aab5c2;
  line-height: 1.45;
  font-size: 12px;
}

.sidebar-toggle {
  width: 100%;
  margin-top: 12px;
  background: #1d2a38;
  border-color: #314358;
  color: #fff;
}

.main {
  min-width: 0;
  max-height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 4;
}

.topbar h2 {
  margin: 0;
  font-size: 23px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.content {
  padding: 22px 24px 34px;
  display: grid;
  gap: 18px;
}

.button {
  min-height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  box-shadow: var(--shadow-sm);
}

.button:hover {
  background: var(--field-hover);
  border-color: var(--muted-2);
}

.button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(29, 92, 150, 0.2);
}

.button.primary:hover {
  background: var(--blue-strong);
  border-color: var(--blue-strong);
}

.button.danger {
  color: var(--red);
}

.button.danger:hover {
  background: var(--red-soft);
  border-color: var(--red);
}

.button.small {
  min-height: 26px;
  padding: 4px 9px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.icon-only {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-weight: 800;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
}

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: 18px;
}

.stat {
  padding: 16px;
  min-height: 108px;
  display: grid;
  align-content: space-between;
  border-left: 4px solid var(--blue);
}

.stat:nth-child(2) {
  border-left-color: var(--amber);
}

.stat:nth-child(3) {
  border-left-color: var(--green);
}

.stat:nth-child(4) {
  border-left-color: var(--teal);
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  font-size: 30px;
  line-height: 1;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.section-title h3 {
  margin: 0;
  font-size: 16px;
}

.section-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(4, minmax(130px, 180px));
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 4px;
}

.field label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  min-height: 32px;
  outline: none;
  font-size: 13px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 92, 150, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  background: #f0f3f7;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f7f9fc;
}

.name-cell strong {
  display: block;
  margin-bottom: 3px;
}

.name-cell span {
  color: var(--muted);
  font-size: 12px;
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #edf2f7;
  color: #455160;
  border: 1px solid #dfe5ed;
  white-space: nowrap;
}

.badge.hot {
  color: var(--red);
  background: #fff0ee;
  border-color: #f3c7c1;
}

.badge.good {
  color: var(--green);
  background: #eefaf3;
  border-color: #bde6cf;
}

.badge.warn {
  color: var(--amber);
  background: #fff7eb;
  border-color: #efd0a3;
}

.score {
  height: 8px;
  width: 96px;
  background: #e5e9ef;
  border-radius: 99px;
  overflow: hidden;
}

.score span {
  display: block;
  height: 100%;
  background: var(--green);
}

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

.quick-add {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 0.9fr auto;
  gap: 10px;
  align-items: end;
}

.list {
  display: grid;
  gap: 9px;
}

.item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.item strong {
  display: block;
}

.item p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.item-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-entry {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}

.timeline-entry:hover {
  background: var(--field);
}

.timeline-entry:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.timeline-entry:last-child {
  border-bottom: 0;
}

.timeline-entry time {
  color: var(--muted);
  font-size: 12px;
}

.timeline-entry p {
  margin: 3px 0 0;
  color: var(--ink-2);
  line-height: 1.4;
}

.timeline-next {
  font-size: 12px;
  color: var(--muted);
}

.empty {
  padding: 24px;
  border: 1px dashed #c7d0dc;
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--muted);
  text-align: center;
}

.drawer-backdrop {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 248px;
  right: 0;
  background: rgba(15, 23, 42, 0.18);
  z-index: 8;
}

@media (max-width: 980px) {
  .drawer-backdrop {
    left: 0;
    background: rgba(15, 23, 42, 0.38);
  }
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(820px, 100vw);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  z-index: 9;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
}

.drawer-head {
  flex-shrink: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.drawer-head-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 22px 12px;
}

.drawer-title-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-title-btn {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: text;
  text-align: left;
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}

.drawer-title-btn:hover {
  background: var(--field);
  padding: 2px 6px;
  margin: -2px -6px;
}

.drawer-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.2;
}

.drawer-title-input {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  border: 1px solid var(--blue) !important;
  background: var(--panel) !important;
  padding: 2px 6px !important;
  margin: -2px -6px !important;
  border-radius: var(--radius-sm) !important;
  width: calc(100% + 12px);
  box-shadow: 0 0 0 3px rgba(29, 92, 150, 0.15) !important;
}

.drawer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.drawer-chips .iedit {
  width: auto;
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  min-height: 26px;
}

.drawer-chips .iedit .iedit-label {
  text-transform: uppercase;
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  display: inline;
}

.drawer-chips .iedit .iedit-value {
  font-size: 12px;
  font-weight: 500;
  display: inline;
  color: var(--ink);
  min-height: 0;
}

.drawer-chips .iedit:hover {
  background: var(--field-hover);
  border-color: var(--muted-2);
}

.drawer-chips .iedit.editing {
  padding: 2px 6px;
  background: var(--panel);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 92, 150, 0.15);
}

.drawer-chips .iedit.editing .iedit-input {
  width: auto;
  min-width: 110px;
}

.drawer-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 22px 0;
}

.qa {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 12px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  min-height: 30px;
}

.qa:hover {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue);
}

.qa-primary {
  background: var(--blue-soft);
  border-color: rgba(29, 92, 150, 0.25);
  color: var(--blue);
}

.qa-primary:hover {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.qa-key {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.qa-val {
  font-weight: 500;
}

.drawer-info-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  padding: 14px 22px 6px;
}

.info-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.info-key {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.info-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.info-chip.hot .info-val {
  color: var(--red);
}

.info-chip.active .info-val {
  color: var(--blue);
}

.drawer-head-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.drawer-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 1px;
  padding: 0 22px 14px;
  background: var(--panel);
}

.dstat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 14px 8px 0;
}

.dstat + .dstat {
  border-left: 1px solid var(--line-soft);
  padding-left: 14px;
}

.dstat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.dstat-value {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.dstat-value small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 2px;
}

.drawer-tabs {
  display: flex;
  gap: 0;
  padding: 0 16px;
  border-top: 1px solid var(--line-soft);
  overflow-x: auto;
  scrollbar-width: thin;
}

.dtab {
  border: 0;
  background: transparent;
  padding: 10px 14px;
  color: var(--muted);
  min-height: 38px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.dtab:hover {
  color: var(--ink);
}

.dtab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.drawer-body {
  flex: 1;
  padding: 18px 22px 28px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  gap: 4px;
  overflow: auto;
}

.tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 9px 12px;
  color: var(--muted);
  min-height: 36px;
  font-size: 13px;
}

.tabs button.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* Overview grid + cards */
.ov-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.ov-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.ov-card.ov-wide {
  grid-column: 1 / -1;
}

.ov-h {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ov-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.ov-danger {
  grid-column: 1 / -1;
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

/* Inline-edit fields */
.iedit {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 10px;
  background: var(--field);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
  min-width: 0;
  font: inherit;
  color: inherit;
  width: 100%;
}

.iedit:hover {
  background: var(--field-hover);
  border-color: var(--line);
}

.iedit.iedit-wide {
  grid-column: 1 / -1;
}

.iedit-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: block;
}

.iedit-value {
  font-size: 13px;
  color: var(--ink);
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.4;
  min-height: 18px;
  display: block;
}

.iedit-empty {
  color: var(--muted-2);
  font-style: italic;
  font-weight: 400;
}

.iedit.editing {
  background: var(--panel);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 92, 150, 0.12);
  padding: 6px 10px;
}

.iedit-input {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 20px;
  font-size: 13px;
  color: var(--ink);
  width: 100%;
}

.iedit-input:focus {
  box-shadow: none;
  outline: none;
}

textarea.iedit-input {
  min-height: 60px;
  resize: vertical;
}

select.iedit-input {
  background: transparent;
}

@media (max-width: 720px) {
  .ov-grid {
    grid-template-columns: 1fr;
  }
  .ov-fields {
    grid-template-columns: 1fr;
  }
  .drawer-head-top {
    flex-direction: column;
    gap: 10px;
  }
  .drawer-head-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.compact-form {
  margin-bottom: 14px;
}

.brief {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.7fr 0.9fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.brief div {
  display: grid;
  gap: 5px;
}

.brief span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.brief strong {
  line-height: 1.35;
  font-size: 13px;
}

.value-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
}

.metric-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  margin: 8px 0;
}

.metric-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.lane {
  min-width: 240px;
  background: #eef2f6;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.lane h4 {
  margin: 0 0 10px;
  font-size: 13px;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.export-card {
  padding: 15px;
}

.export-card p {
  color: var(--muted);
  min-height: 58px;
  line-height: 1.45;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
  overflow-x: auto;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.month-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.calendar-weekday {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-weekday:nth-child(7) {
  border-right: 0;
}

.calendar-cell {
  min-height: 124px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 8px;
  text-align: left;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 7px;
  align-content: start;
}

.calendar-cell:nth-child(7n) {
  border-right: 0;
}

.calendar-cell:hover,
.calendar-cell.selected {
  background: #eef6ff;
  box-shadow: inset 0 0 0 2px var(--blue);
}

.calendar-cell.muted-day {
  background: #f8fafc;
  color: #98a4b3;
}

.calendar-cell.today-cell .calendar-date {
  background: var(--blue);
  color: #fff;
}

.calendar-date {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.calendar-items {
  display: grid;
  gap: 4px;
  align-content: start;
}

.calendar-pill {
  min-height: 22px;
  border-radius: 5px;
  padding: 3px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #f4f7fb;
}

.calendar-pill.appointment {
  border-color: #b9d9f4;
  background: #eaf5ff;
  color: #174b78;
}

.calendar-pill.task {
  border-color: #ecd1a8;
  background: #fff6e8;
  color: #7a430d;
}

.calendar-pill.event {
  border-color: #b8dfd7;
  background: #ecfaf7;
  color: #195f63;
}

.calendar-more {
  color: var(--muted);
  font-size: 12px;
}

.day-panel {
  position: sticky;
  top: 96px;
}

.network-model {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.network-node {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 10px;
  text-align: center;
  font-weight: 800;
  color: var(--blue-strong);
}

.day {
  min-height: 210px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.day h4 {
  margin: 0 0 9px;
  font-size: 13px;
}

.stacked-table {
  margin-top: 12px;
}

.theme-dark .topbar {
  background: rgba(18, 26, 36, 0.9);
}

.theme-dark th,
.theme-dark .calendar-weekday {
  background: #172231;
}

.theme-dark tbody tr:hover,
.theme-dark .calendar-cell:hover,
.theme-dark .calendar-cell.selected {
  background: #16283a;
}

.theme-dark .item,
.theme-dark .metric-card,
.theme-dark .network-node,
.theme-dark .day,
.theme-dark .calendar-cell {
  background: var(--panel);
}

.theme-dark .calendar-cell.muted-day,
.theme-dark .empty,
.theme-dark .brief {
  background: #0f1722;
}

.theme-dark .badge {
  background: #1b2736;
  color: #cbd6e3;
  border-color: #334155;
}

.theme-dark .badge.hot {
  color: #f3aaa3;
  background: #3a1e22;
  border-color: #7f3439;
}

.theme-dark .badge.good {
  color: #9de2b8;
  background: #173021;
  border-color: #2d6b45;
}

.theme-dark .badge.warn {
  color: #f2c27f;
  background: #372819;
  border-color: #795322;
}

.theme-dark .calendar-pill {
  background: #182333;
}

.theme-dark .calendar-pill.appointment {
  border-color: #2c6798;
  background: #12304a;
  color: #b8dbf5;
}

.theme-dark .calendar-pill.task {
  border-color: #7a5322;
  background: #332311;
  color: #f1c684;
}

.theme-dark .calendar-pill.event {
  border-color: #296a66;
  background: #123331;
  color: #a2e3dc;
}

.mobile-menu {
  display: none;
}

@media (max-width: 1080px) {
  .grid.stats,
  .export-grid,
  .calendar-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-add {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 7;
    height: auto;
    overflow: visible;
    padding: 12px;
    gap: 10px;
  }

  .brand {
    justify-content: space-between;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .nav {
    display: none;
  }

  .nav.open {
    display: grid;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .main {
    max-height: none;
    overflow: visible;
  }

  .content {
    padding: 16px;
  }

  .grid.stats,
  .toolbar,
  .quick-add,
  .split,
  .form-grid,
  .brief,
  .value-grid,
  .network-model,
  .export-grid,
  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .month-calendar {
    grid-template-columns: repeat(7, minmax(72px, 1fr));
    overflow-x: auto;
  }

  .calendar-cell {
    min-height: 104px;
  }

  .day-panel {
    position: static;
  }

  .drawer {
    width: 100vw;
  }
}

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--page);
  color: var(--ink);
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-card .auth-logo {
  width: 96px;
  height: auto;
  margin: 0 auto 18px;
  display: block;
}

.auth-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.auth-card p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-card .button {
  margin-top: 4px;
}

.auth-card .error {
  color: var(--red);
  font-size: 13px;
}

.auth-card code {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
}

.save-status-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 6px;
}

.save-status {
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  white-space: nowrap;
}

.save-status.ok { color: var(--green); border-color: rgba(31, 122, 79, 0.3); }
.save-status.dirty { color: var(--amber); border-color: rgba(160, 93, 18, 0.3); }
.save-status.saving { color: var(--blue); border-color: rgba(29, 92, 150, 0.3); }
.save-status.error { color: var(--red); border-color: rgba(168, 58, 50, 0.4); }

.save-status-email {
  font-size: 12px;
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 48px 32px;
  text-align: center;
  max-width: 560px;
  margin: 32px auto;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.empty-state p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.5;
}

.empty-state-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.empty-state-tip {
  font-size: 12px;
  color: var(--muted);
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.empty-state-tip code {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
}

.danger-link {
  color: var(--red) !important;
  border-color: transparent !important;
  background: transparent !important;
  font-size: 11px;
  opacity: 0.7;
}

.danger-link:hover {
  opacity: 1;
  text-decoration: underline;
}

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

.today-metrics .metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.today-metrics .metric strong {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.today-metrics .metric span {
  font-size: 12px;
  color: var(--muted);
}

.today-metrics .metric.metric-hot strong {
  color: var(--red);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 900;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 640px);
  max-height: 88vh;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 901;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
  font-size: 17px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.filter-badge {
  background: var(--blue);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.filter-badge:hover {
  background: var(--blue-strong);
}

.filter-badge-wrap {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--panel);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1000;
  font-size: 13px;
  max-width: 90vw;
}

.toast .button {
  background: var(--panel);
  color: var(--ink);
  border: none;
  font-weight: 500;
}

.toast .button.ghost {
  background: transparent;
  color: inherit;
  border: none;
  padding: 4px 8px;
  font-size: 18px;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.task-row:hover {
  background: var(--field);
  border-color: var(--muted-2);
  box-shadow: var(--shadow-sm);
}

.task-row:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.task-row.task-done {
  opacity: 0.55;
}

.task-row.task-done .task-row-title {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.task-row.task-overdue {
  border-left: 3px solid var(--red);
  padding-left: 10px;
}

.task-check {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
}

.task-check:hover {
  background: var(--field-hover);
}

.task-check .check-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--muted-2);
  background: transparent;
  transition: all 0.12s ease;
  position: relative;
}

.task-check:hover .check-circle {
  border-color: var(--green);
}

.task-check .check-circle.checked {
  background: var(--green);
  border-color: var(--green);
}

.task-check .check-circle.checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.task-row-body {
  min-width: 0;
}

.task-row-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  align-items: center;
}

.task-type-pill {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--field);
  color: var(--ink-2);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.task-owner {
  margin-left: auto;
  opacity: 0.8;
}

.task-row-due {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.task-row-due.hot {
  color: var(--red);
  font-weight: 600;
}

.task-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.ts-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}

.ts-chip:hover {
  border-color: var(--muted-2);
  box-shadow: var(--shadow-sm);
}

.ts-chip.active {
  background: var(--blue-soft);
  border-color: var(--blue);
}

.ts-chip strong {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}

.ts-chip span {
  font-size: 12px;
  color: var(--muted);
}

.ts-chip:first-child strong { color: var(--red); }
.ts-chip:nth-child(2) strong { color: var(--amber); }

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.modal-status-note {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 12px;
  background: var(--field);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.modal-status-note.done {
  color: var(--green);
  background: var(--green-soft);
}

.filter-select {
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  min-height: 28px;
}

.chip-primary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  min-height: 26px;
  transition: all 0.12s;
}

.chip-primary:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.chip-primary.active {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}

.primary-star {
  color: var(--amber);
}

.primary-contact-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--field);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.primary-contact-card:hover {
  background: var(--field-hover);
  border-color: var(--muted-2);
}

.pcc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.pcc-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.pcc-role {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.pcc-star {
  color: var(--amber);
  font-size: 18px;
  flex-shrink: 0;
}

.pcc-contacts {
  font-size: 12px;
  color: var(--ink-2);
}

.pcc-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 4px;
}

.pcc-empty p {
  margin: 0;
  line-height: 1.5;
}

.pcc-empty .link-button {
  color: var(--blue);
}

.ov-h-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

.ov-h-row .ov-h {
  margin: 0;
}

.primary-picker {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  min-height: 26px;
  max-width: 220px;
}

/* Day timeline */
.day-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.day-timeline-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--field);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}

.tl-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tl-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 2px;
  padding-left: 4px;
}

.tl-slot {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: stretch;
}

.tl-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
  padding-top: 12px;
  text-align: right;
  white-space: nowrap;
}

.tl-row {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.tl-row:hover {
  background: var(--field);
  border-color: var(--muted-2);
  box-shadow: var(--shadow-sm);
}

.tl-marker {
  width: 4px;
  align-self: stretch;
  border-radius: 4px;
  background: var(--muted-2);
}

.tl-marker-appt { background: var(--blue); }
.tl-marker-task { background: var(--amber); }
.tl-marker-event { background: var(--teal); }

.tl-body {
  min-width: 0;
}

.tl-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 3px;
}

.tl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  color: var(--muted);
  align-items: center;
}

.tl-pill {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--field);
}

.tl-pill-meeting { color: var(--blue); border-color: rgba(29, 92, 150, 0.25); background: var(--blue-soft); }
.tl-pill-task { color: var(--amber); border-color: rgba(180, 83, 9, 0.25); background: var(--amber-soft); }
.tl-pill-event { color: var(--teal); border-color: rgba(15, 118, 110, 0.25); background: var(--teal-soft); }

.tl-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}

.tl-status-scheduled { color: var(--blue); background: var(--blue-soft); }
.tl-status-met { color: var(--green); background: var(--green-soft); }
.tl-status-missed { color: var(--red); background: var(--red-soft); }

.tl-owner {
  margin-left: auto;
  opacity: 0.8;
}

/* Event list */
.event-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.event-row:hover {
  background: var(--field);
  border-color: var(--muted-2);
  box-shadow: var(--shadow-sm);
}

.event-date {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid var(--line-soft);
  padding-right: 12px;
}

.event-date strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.event-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.event-goal {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.inline-select {
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  max-width: 140px;
}

.inline-select:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

table.compact th.hide-compact,
table.compact td.hide-compact {
  display: none;
}

.bulk-col {
  width: 32px;
  text-align: center;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(29, 92, 150, 0.08);
  border: 1px solid rgba(29, 92, 150, 0.25);
  border-radius: 10px;
  margin-bottom: 12px;
}

.bulk-actions label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.bulk-actions select {
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.row-selected {
  background: rgba(29, 92, 150, 0.07);
}

.contact-link {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.contact-link:hover {
  color: var(--blue-strong);
  border-bottom-style: solid;
}

.brief-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 14px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0 0 14px;
  font-size: 13px;
}

.button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.button.ghost:hover {
  color: var(--ink);
  border-color: var(--ink);
}

@media (max-width: 720px) {
  .save-status-email { display: none; }
  .save-status-wrap { gap: 4px; }

  .top-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .top-actions .button {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    padding: 8px 10px;
  }

  .today-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .today-metrics .metric strong { font-size: 22px; }

  .modal {
    width: 96vw;
    max-height: 92vh;
  }

  .item.with-check .item-actions .button {
    min-height: 40px;
    padding: 8px 12px;
  }

  .task-check {
    width: 48px;
    height: 48px;
  }

  .task-check .check-circle {
    width: 26px;
    height: 26px;
  }

  table { font-size: 13px; }
  .name-cell strong { font-size: 14px; }
}

/* Touch-device tweaks */
@media (hover: none) and (pointer: coarse) {
  .contact-link {
    padding: 4px 0;
    border-bottom: 1px solid currentColor;
  }
  .button {
    min-height: 40px;
  }
}
