@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #root { height: 100%; overflow: hidden; }

body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: #fff;
  color: #37352f;
  -webkit-font-smoothing: antialiased;
}

:root {
  --bg:       #ffffff;
  --bg-side:  #f7f7f5;
  --bg-hover: #efefee;
  --bg-sel:   #e8e8e6;
  --border:   #e9e9e7;
  --text-1:   #37352f;
  --text-2:   #787774;
  --text-3:   #acaba8;
  --blue:     #2383e2;
  --blue-bg:  #e8f2fd;
  --green:    #0f7b6c;
  --green-bg: #e8f7f4;
  --red:      #e03e3e;
  --red-bg:   #fdeaea;
  --yellow:   #dfab01;
  --yellow-bg:#fef9e7;
  --purple:   #6940a5;
  --radius:   6px;
  --sidebar:  240px;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

/* ── Layout ── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-top {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.workspace-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius);
  cursor: default;
}
.workspace-icon { font-size: 16px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 6px; }
.nav-section { margin-bottom: 18px; }
.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 8px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-add-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.1s;
}
.nav-add-btn:hover { background: var(--bg-sel); color: var(--text-1); }
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius);
  text-align: left;
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-1); }
.nav-item.active { background: var(--bg-sel); color: var(--text-1); font-weight: 600; }
.nav-icon { font-size: 14px; flex-shrink: 0; }
.nav-item-av {
  width: 18px; height: 18px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; flex-shrink: 0;
}
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-av {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
  background: var(--blue-bg); color: var(--blue);
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-online { font-size: 11px; color: var(--green); }
.signout-btn { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 14px; padding: 4px; border-radius: 4px; }
.signout-btn:hover { background: var(--bg-sel); color: var(--text-1); }

/* ── Main ── */
.main { flex: 1; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 16px; font-weight: 700; color: var(--text-1); }
.page-actions { display: flex; align-items: center; gap: 8px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 14px; border-radius: var(--radius); border: none;
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.1s; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-blue  { background: var(--blue);   color: #fff; }
.btn-blue:hover:not(:disabled)  { background: #1a6fc4; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-1); }
.btn-red   { background: transparent; color: var(--red); border: 1px solid var(--red-bg); }
.btn-red:hover:not(:disabled)   { background: var(--red-bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Inputs ── */
.input {
  width: 100%; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-1);
  font-family: 'Inter', sans-serif; font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--blue); }
.input::placeholder { color: var(--text-3); }
textarea.input { resize: vertical; min-height: 80px; }
select.input { cursor: pointer; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }

/* ── Alert ── */
.alert { padding: 8px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }
.alert-err { background: var(--red-bg); color: var(--red); }
.alert-ok  { background: var(--green-bg); color: var(--green); }

/* ── Tag ── */
.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.tag-shared  { background: var(--green-bg); color: var(--green); }
.tag-private { background: var(--yellow-bg); color: var(--yellow); }
.tag-todo    { background: var(--bg-sel); color: var(--text-2); }
.tag-prog    { background: var(--blue-bg); color: var(--blue); }
.tag-done    { background: var(--green-bg); color: var(--green); }

/* ── Modal ── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; animation: fadeIn 0.1s ease;
}
.modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 24px; min-width: 400px; max-width: 92vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12); animation: slideUp 0.15s ease;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
@keyframes fadeIn  { from { opacity: 0; }              to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Loading / Empty states ── */
.loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-3); font-size: 14px; }
.empty   { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 12px; color: var(--text-2); }
.empty-icon { font-size: 40px; }
.empty-text { font-size: 14px; color: var(--text-2); }

/* ── Auth ── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-side); }
.auth-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 36px; width: 380px; max-width: 92vw; box-shadow: 0 4px 24px rgba(0,0,0,0.06); }
.auth-logo { font-size: 22px; font-weight: 700; color: var(--text-1); margin-bottom: 4px; }
.auth-sub  { font-size: 13px; color: var(--text-2); margin-bottom: 24px; }
.auth-tabs { display: flex; background: var(--bg-side); border-radius: var(--radius); padding: 3px; margin-bottom: 22px; }
.auth-tab  { flex: 1; padding: 7px; border: none; background: transparent; color: var(--text-2); font-family: 'Inter',sans-serif; font-size: 13px; font-weight: 500; cursor: pointer; border-radius: 4px; transition: all 0.1s; }
.auth-tab.active { background: var(--bg); color: var(--text-1); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* ── Chat ── */
.chat-wrap { display: flex; flex-direction: column; height: 100%; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px 24px; display: flex; flex-direction: column; gap: 1px; }
.msg       { max-width: 72%; }
.msg-own   { align-self: flex-end; }
.msg-other { align-self: flex-start; }
.msg-head  { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.msg-user  { font-size: 12px; font-weight: 600; color: var(--text-2); }
.msg-time  { font-size: 11px; color: var(--text-3); font-family: 'DM Mono',monospace; }
.msg-bubble { padding: 8px 12px; border-radius: 8px; font-size: 14px; line-height: 1.5; word-break: break-word; display: inline-block; }
.bubble-other { background: var(--bg-side); color: var(--text-1); border: 1px solid var(--border); }
.bubble-own   { background: var(--blue); color: #fff; }
.chat-input-row { display: flex; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); }
.chat-input { flex: 1; }
.send-btn { width: 36px; height: 36px; flex-shrink: 0; padding: 0; border-radius: var(--radius); font-size: 16px; }

/* ── Notes ── */
.notes-layout    { display: flex; height: 100%; overflow: hidden; }
.notes-list-pane { width: 240px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; background: var(--bg-side); }
.notes-list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.notes-list-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.notes-list      { flex: 1; overflow-y: auto; padding: 6px; }
.note-row        { padding: 8px 10px; border-radius: var(--radius); cursor: pointer; margin-bottom: 2px; border: 1px solid transparent; transition: all 0.1s; }
.note-row:hover  { background: var(--bg-hover); }
.note-row.active { background: var(--bg-sel); border-color: var(--border); }
.note-row-title  { font-size: 13px; font-weight: 500; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.note-row-preview { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.note-row-meta   { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); font-family: 'DM Mono',monospace; }
.note-editor     { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.note-edit-head  { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.note-title-input { flex: 1; font-size: 18px; font-weight: 700; color: var(--text-1); background: transparent; border: none; outline: none; font-family: 'Inter',sans-serif; }
.note-body       { flex: 1; padding: 20px; font-size: 14px; color: var(--text-1); background: transparent; border: none; outline: none; resize: none; line-height: 1.7; overflow-y: auto; font-family: 'Inter',sans-serif; }

/* ── Spreadsheet ── */
.sheet-wrap  { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.sheet-tabs  { display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--bg-side); overflow-x: auto; flex-shrink: 0; }
.sheet-tab   { padding: 10px 14px; font-size: 13px; font-weight: 500; color: var(--text-2); border: none; background: transparent; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; transition: all 0.1s; }
.sheet-tab:hover  { color: var(--text-1); }
.sheet-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.sheet-tab-new    { color: var(--text-3); }
.sheet-toolbar    { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sheet-name       { font-size: 14px; font-weight: 600; color: var(--text-1); }
.table-wrap       { flex: 1; overflow: auto; }
.db-table         { width: 100%; border-collapse: collapse; font-size: 13px; }
.db-table th      { text-align: left; padding: 9px 14px; background: var(--bg-side); color: var(--text-2); font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--border); position: sticky; top: 0; white-space: nowrap; }
.db-table td      { border-bottom: 1px solid var(--border); vertical-align: middle; }
.db-table tr:hover td { background: var(--bg-side); }
.cell             { cursor: text; min-width: 120px; max-width: 280px; }
.cell-val         { display: block; padding: 9px 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; color: var(--text-1); }
.cell-link        { color: var(--blue); text-decoration: none; }
.cell-link:hover  { text-decoration: underline; }
.cell-edit        { width: 100%; padding: 9px 14px; background: #fff; border: none; border-left: 2px solid var(--blue); color: var(--text-1); font-family: 'Inter',sans-serif; font-size: 13px; outline: none; min-width: 120px; }
.row-num          { padding: 9px 14px; color: var(--text-3); font-family: 'DM Mono',monospace; font-size: 11px; text-align: center; width: 40px; user-select: none; }

/* ── Projects ── */
.proj-layout   { display: flex; height: 100%; overflow: hidden; }
.proj-sidebar  { width: 220px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg-side); }
.proj-side-head { padding: 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.proj-side-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.proj-list     { flex: 1; overflow-y: auto; padding: 6px; }
.proj-item     { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius); cursor: pointer; transition: background 0.1s; border: 1px solid transparent; margin-bottom: 2px; }
.proj-item:hover { background: var(--bg-hover); }
.proj-item.active { background: var(--bg-sel); border-color: var(--border); }
.proj-dot      { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.proj-item-name { font-size: 13px; font-weight: 500; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.board         { flex: 1; display: flex; gap: 14px; padding: 16px; overflow: auto; align-items: flex-start; }
.board-col     { width: 280px; flex-shrink: 0; background: var(--bg-side); border-radius: 8px; border: 1px solid var(--border); display: flex; flex-direction: column; max-height: calc(100vh - 160px); }
.board-col-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.board-col-title { font-size: 13px; font-weight: 600; color: var(--text-1); flex: 1; }
.board-col-count { font-size: 12px; color: var(--text-3); background: var(--bg-sel); padding: 1px 7px; border-radius: 10px; }
.board-tasks   { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.task-card     { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; cursor: pointer; transition: box-shadow 0.1s; }
.task-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.task-title    { font-size: 13px; font-weight: 500; color: var(--text-1); line-height: 1.4; margin-bottom: 6px; }
.task-title.done { text-decoration: line-through; color: var(--text-3); }
.task-desc     { font-size: 12px; color: var(--text-3); line-height: 1.5; margin-bottom: 8px; }
.task-foot     { display: flex; align-items: center; justify-content: space-between; }
.task-assignee { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-2); }
.task-av       { width: 16px; height: 16px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; }
.task-due      { font-size: 11px; color: var(--text-3); font-family: 'DM Mono',monospace; }
.task-due.overdue { color: var(--red); }
.board-add     { padding: 8px 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.progress-wrap { padding: 10px 24px 0; flex-shrink: 0; }
.progress-row  { display: flex; align-items: center; gap: 10px; }
.progress-bar  { flex: 1; height: 3px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width 0.3s; }
.progress-text { font-size: 12px; color: var(--text-3); font-family: 'DM Mono',monospace; white-space: nowrap; }

/* ── Color dots for project picker ── */
.color-picker  { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot     { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all 0.1s; }
.color-dot.selected { border-color: var(--text-1); transform: scale(1.1); }

/* Status chip */
.status-chips  { display: flex; gap: 6px; }
.status-chip   { flex: 1; padding: 7px; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; font-family: 'Inter',sans-serif; font-size: 12px; font-weight: 500; cursor: pointer; text-align: center; transition: all 0.1s; color: var(--text-2); }
.status-chip.active { background: var(--blue-bg); border-color: var(--blue); color: var(--blue); font-weight: 600; }

/* User list in modal */
.user-list-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; margin-bottom: 6px; transition: background 0.1s; }
.user-list-item:hover { background: var(--bg-hover); }
