:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #ffffff;
  --panel-soft: #fbfaf7;
  --ink: #1f2528;
  --muted: #667075;
  --line: #dfd9cd;
  --accent: #2f6f63;
  --accent-dark: #224f47;
  --warn: #a65f00;
  --danger: #a33a32;
  --ok: #2f6f63;
  --shadow: 0 18px 50px rgba(35, 31, 24, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { border: 0; cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 272px 1fr; }

.sidebar {
  background: #202725;
  color: #f8f5ed;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 100vh;
  overflow-y: auto;
}

.brand {
  display: grid;
  gap: 4px;
  padding: 2px 6px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand strong { font-size: 19px; letter-spacing: 0; }
.brand span { font-size: 13px; color: rgba(248, 245, 237, 0.68); }

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

.nav button, .quick-link {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  color: rgba(248, 245, 237, 0.78);
  text-align: left;
  text-decoration: none;
  font-size: 13px;
}

.nav button.active, .nav button:hover, .quick-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav svg, .quick-link svg, .icon-button svg { width: 18px; height: 18px; flex: 0 0 auto; }

.sidebar-stats {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.sidebar-stats div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: rgba(248, 245, 237, 0.62);
  font-size: 11px;
}
.sidebar-stats strong { color: #d8bd78; font-size: 12px; }
.sidebar-block {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}
.sidebar-title {
  color: #d8bd78;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.sidebar-links { display: grid; gap: 4px; }
.sidebar-links a {
  color: rgba(248, 245, 237, 0.78);
  font-size: 12px;
  line-height: 1.25;
  text-decoration: none;
}
.sidebar-links a:hover { color: #fff; }
.sidebar-check-progress {
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}
.sidebar-check-progress span {
  display: block;
  height: 100%;
  background: #d8bd78;
}
.sidebar-checks { display: grid; gap: 6px; }
.sidebar-checks label {
  display: grid;
  grid-template-columns: 16px 38px 1fr;
  gap: 6px;
  align-items: start;
  color: rgba(248, 245, 237, 0.78);
  font-size: 11px;
  line-height: 1.25;
  cursor: pointer;
}
.sidebar-checks input { width: 14px; height: 14px; margin: 1px 0 0; accent-color: #d8bd78; }
.sidebar-checks label.done { color: rgba(248, 245, 237, 0.48); }
.sidebar-checks label.done > span:last-child { text-decoration: line-through; }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; }
.sync-pill { padding: 10px 12px; border-radius: 8px; background: rgba(255,255,255,.08); color: rgba(248,245,237,.78); font-size: 12px; }

.main { min-width: 0; padding: 28px; display: grid; gap: 20px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.eyebrow { margin: 0 0 6px; color: var(--accent-dark); font-size: 13px; font-weight: 700; text-transform: uppercase; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 44px); line-height: 1.02; letter-spacing: 0; }
h2 { font-size: 20px; letter-spacing: 0; }
h3 { font-size: 15px; letter-spacing: 0; }
.subtitle { margin-top: 8px; max-width: 780px; color: var(--muted); font-size: 15px; line-height: 1.5; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.primary-button, .secondary-button, .ghost-button, .icon-button {
  min-height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  white-space: nowrap;
}
.primary-button { background: var(--accent); color: #fff; }
.secondary-button { background: #e9e3d7; color: var(--ink); }
.ghost-button { background: transparent; color: var(--accent-dark); }
.icon-button { width: 40px; padding: 0; background: #e9e3d7; color: var(--ink); }

.status-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.status-card, .panel, .task-card, .alert-card, .metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.status-card { padding: 16px; min-height: 112px; display: grid; align-content: space-between; gap: 14px; }
.status-card span { color: var(--muted); font-size: 13px; }
.status-card strong { display: block; font-size: 28px; line-height: 1; margin-top: 5px; }
.status-card footer { color: var(--muted); font-size: 12px; }

.routine-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 18px; }
.panel { min-width: 0; padding: 18px; display: grid; gap: 16px; align-content: start; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-header p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.alert-list, .task-list, .event-list, .agent-list, .integration-list, .link-grid, .checklist-list { display: grid; gap: 10px; }

.alert-card, .task-card { padding: 14px; display: grid; gap: 8px; }
.alert-card { border-left: 4px solid var(--warn); }
.alert-card.danger { border-left-color: var(--danger); }
.item-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item-title { font-weight: 700; line-height: 1.35; }
.item-meta, .item-note { color: var(--muted); font-size: 13px; line-height: 1.4; }

.badge {
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.badge.ok { color: #205048; background: #dcebe6; }
.badge.warn { color: #7a4700; background: #f7e5c7; }
.badge.danger { color: #7d251f; background: #f4d8d5; }
.badge.neutral { color: #3c464a; background: #ece8df; }

.event {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 12px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.event-time { color: var(--accent-dark); font-weight: 800; font-size: 13px; }
.event-title { font-weight: 700; line-height: 1.3; }

.metrics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metric-card { box-shadow: none; padding: 14px; display: grid; gap: 6px; }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-card strong { font-size: 22px; }
.progress-track { height: 7px; border-radius: 999px; background: #e5dfd4; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); }

.kanban-shell { overflow: hidden; }
.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(190px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.kanban-column {
  min-width: 190px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}
.kanban-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}
.kanban-column-head span {
  min-width: 26px;
  min-height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #e9e3d7;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}
.kanban-cards { display: grid; gap: 10px; }
.kanban-card {
  min-height: 122px;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(35, 31, 24, 0.06);
}
.kanban-empty {
  min-height: 86px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}
.content-kanban-board {
  min-height: calc(100vh - 190px);
  align-items: start;
}
.content-kanban-column {
  min-width: 190px;
  min-height: calc(100vh - 220px);
}
.content-card {
  align-content: start;
  min-height: 250px;
}
.content-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.content-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 999px;
  background: #ece6da;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-pill {
  background: #e0eadf;
  color: var(--accent-dark);
}
.content-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.content-progress-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.content-progress-row strong {
  color: var(--accent-dark);
}
.content-card-hint {
  padding-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.content-field {
  display: grid;
  gap: 3px;
}
.content-field span {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.content-field p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.content-card details {
  color: var(--muted);
  font-size: 13px;
}
.content-card summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 800;
}
.content-card details[open] {
  display: grid;
  gap: 8px;
}
.compact-dashboard { grid-template-columns: minmax(0, .9fr) minmax(320px, .55fr); }

.daily-section { grid-template-columns: minmax(0, 1fr) minmax(340px, .55fr); }
.link-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.domain-link, .checklist-item { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 8px; }
.domain-link {
  min-height: 92px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  padding: 14px;
  color: var(--ink);
  text-decoration: none;
}
.domain-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.domain-link strong, .domain-link span, .domain-link small { display: block; }
.domain-link span { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.domain-link small { color: var(--accent-dark); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checklist-progress { margin-top: -6px; }
.checklist-list { max-height: 430px; overflow-y: auto; padding-right: 2px; }
.checklist-item {
  min-height: 54px;
  display: grid;
  grid-template-columns: 18px 48px 1fr;
  align-items: start;
  gap: 10px;
  padding: 12px;
  color: var(--ink);
  cursor: pointer;
}
.checklist-item input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }
.checklist-item.done { background: #eef5f1; color: var(--muted); }
.checklist-item.done > span:last-child { text-decoration: line-through; }
.check-time { color: var(--accent-dark); font-size: 13px; font-weight: 800; }

.agent-row, .integration-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.agent-row:last-child, .integration-row:last-child { border-bottom: 0; }
.agent-row strong, .integration-row strong { display: block; font-size: 14px; }
.agent-row span, .integration-row span { color: var(--muted); font-size: 12px; }

.operation-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.operation-link {
  min-height: 92px;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  text-decoration: none;
}
.operation-link:hover { border-color: var(--accent); }
.operation-link strong { font-size: 14px; line-height: 1.3; }
.operation-link span { color: var(--muted); font-size: 13px; line-height: 1.35; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-card {
  width: min(440px, 100%);
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.login-card input { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; color: var(--ink); background: var(--panel-soft); }
.empty, .error {
  min-height: 92px;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 8px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}
.error { color: var(--danger); border-color: #e1b8b3; background: #fff7f6; }
.mobile-menu { display: none; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 88vw);
    z-index: 30;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 24px 0 60px rgba(0, 0, 0, .22);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, .32);
  }
  .mobile-menu { display: flex; }
  .routine-grid, .daily-section, .status-strip { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .operation-list { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .main { padding: 18px 14px; }
  .topbar, .panel-header, .item-top { display: grid; }
  .toolbar { justify-content: stretch; }
  .primary-button, .secondary-button, .ghost-button { width: 100%; }
  .metrics-grid { grid-template-columns: 1fr; }
  .link-grid { grid-template-columns: 1fr; }
  .event { grid-template-columns: 1fr; }
  .checklist-item { grid-template-columns: 18px 44px 1fr; }
}
