:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --ink: #17202a;
  --muted: #667085;
  --panel: #ffffff;
  --line: #d7dde5;
  --accent: #166c7d;
  --accent-soft: #e9f5f7;
  --warn: #8b5d33;
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 0 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary,
.tab {
  background: white;
  color: var(--accent);
}

.hidden {
  display: none !important;
}

.brand-logo {
  display: block;
  object-fit: contain;
}

.login-logo {
  width: min(260px, 78vw);
  height: auto;
  margin-bottom: 4px;
}

.sidebar-logo {
  width: min(210px, 100%);
  height: auto;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel,
dialog form {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 16px;
}

p,
.meta,
.error {
  color: var(--muted);
}

.error {
  color: #a33b2f;
  min-height: 20px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 10px 11px;
}

.inline {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.inline input {
  width: auto;
}

.compact-toggle {
  grid-template-columns: auto auto;
  gap: 6px;
  color: var(--ink);
  white-space: nowrap;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.sidebar-head,
.workspace-head,
.section-head,
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.icon-button {
  min-width: 42px;
}

.wide-button {
  width: 100%;
}

.active-nav {
  background: var(--accent);
  color: white;
}

.project-list,
.data-list,
.action-list {
  display: grid;
  gap: 10px;
}

.project,
.data-item,
.email-action {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 12px;
}

.project {
  border-left: 4px solid var(--warn);
  cursor: pointer;
}

.project.active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.workspace {
  padding: 18px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.actions,
.row-actions,
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.split-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-grid,
.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-height: 0;
}

.project-view,
.home-view {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.dashboard-card {
  min-width: 0;
  min-height: 280px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.chat-panel {
  grid-template-rows: auto minmax(220px, 1fr) auto;
  align-content: stretch;
}

.home-chat-card {
  grid-column: 1 / -1;
}

.chat-log {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 10px;
  background: #fbfcfd;
}

.file-row {
  width: 100%;
  min-height: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.file-row-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.compact-button {
  min-height: 30px;
  padding: 0 10px;
}

.home-project-row,
.todo-row,
.member-result {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 2fr) auto;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.todo-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.member-result {
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr);
}

.email-row {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(180px, 2fr) 130px minmax(150px, 1fr) minmax(150px, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.email-row.incoming {
  border-left: 4px solid #166c7d;
  padding-left: 8px;
}

.email-row.outgoing {
  border-left: 4px solid #7a5cdb;
  padding-left: 8px;
}

.direction-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.direction-badge.incoming {
  background: #166c7d;
}

.direction-badge.outgoing {
  background: #7a5cdb;
}

.email-row strong {
  color: var(--accent);
}

.email-date,
.email-from,
.email-to,
.email-status,
.email-party {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-date,
.email-to,
.email-status {
  color: var(--muted);
}

.email-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-row {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 140px minmax(160px, 2fr) minmax(120px, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.calendar-widget {
  display: grid;
  gap: 10px;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto auto;
  gap: 6px;
  align-items: center;
}

.calendar-toolbar strong {
  text-align: center;
  text-transform: capitalize;
}

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

.calendar-weekday {
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 6px;
  text-align: center;
}

.calendar-cell {
  min-height: 86px;
  background: white;
  padding: 6px;
  display: grid;
  align-content: start;
  gap: 5px;
}

.calendar-grid.week .calendar-cell {
  min-height: 150px;
}

.calendar-cell.today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

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

.calendar-cell-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.calendar-events {
  display: grid;
  gap: 4px;
}

.calendar-event {
  min-height: 0;
  display: grid;
  gap: 2px;
  border: 0;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--ink);
  padding: 5px 6px;
  text-align: left;
}

.calendar-event strong,
.calendar-event span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.calendar-event.priority-low {
  border-left-color: #8aa0ad;
}

.calendar-event.priority-high {
  border-left-color: #b7791f;
}

.calendar-event.priority-urgent {
  border-left-color: #b42318;
}

.note-row {
  width: 100%;
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  text-align: left;
}

.note-editor-form {
  gap: 12px;
}

#note-detail-body {
  min-height: 48vh;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  line-height: 1.45;
}

.calendar-date {
  color: var(--accent);
  font-weight: 700;
}

.email-detail-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.email-body {
  max-height: 52vh;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  margin: 0;
  background: #fbfcfd;
  font-family: inherit;
}

.file-row.folder span {
  color: var(--accent);
  font-weight: 700;
}

.file-row small {
  color: var(--muted);
  white-space: nowrap;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.todo-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 180px) minmax(110px, 150px) minmax(160px, 220px) auto;
  gap: 8px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
  align-items: start;
}

.kanban-column {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.kanban-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

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

.kanban-items {
  display: grid;
  gap: 8px;
}

.todo-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: white;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.todo-card.priority-low {
  border-left-color: #8aa0ad;
}

.todo-card.priority-high {
  border-left-color: #b7791f;
}

.todo-card.priority-urgent {
  border-left-color: #b42318;
}

.todo-card.done strong,
.todo-card.done p {
  text-decoration: line-through;
  color: var(--muted);
}

.todo-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.index-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.index-row p {
  margin-top: 6px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
}

.bubble {
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  background: white;
  border: 1px solid var(--line);
}

.bubble.user {
  background: #eaf3ef;
}

.sources,
.meta {
  font-size: 12px;
  margin-top: 6px;
}

.sources a,
.file-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.sources a:hover,
.file-link:hover {
  text-decoration: underline;
}

.email-action {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.approval-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(520px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgb(16 24 40 / 0.38);
}

.project-form {
  width: 100%;
}

.weaviate-dialog-content {
  display: grid;
  gap: 12px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

#weaviate-dialog {
  width: min(960px, calc(100vw - 24px));
}

#weaviate-dialog .data-list {
  max-height: 64vh;
  overflow: auto;
}

#global-settings-dialog {
  width: min(980px, calc(100vw - 24px));
}

.global-settings-form {
  width: 100%;
  display: grid;
  gap: 14px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .home-grid,
  .todo-form,
  .email-row,
  .calendar-row,
  .calendar-toolbar,
  .file-row-wrap,
  .home-project-row,
  .member-result {
    grid-template-columns: 1fr;
  }

  .kanban-board,
  .index-row,
  .email-action {
    display: grid;
  }

  .kanban-board {
    grid-template-columns: 1fr;
  }

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