:root {
  --bg: #f4f5f7;
  --bg-soft: #eef0f3;
  --ink: #1e2330;
  --muted: #6b7385;
  --card: #ffffff;
  --line: #e3e6ec;
  --line-soft: #eceef2;
  --brand: #2f6fed;
  --brand-hover: #1f5bd6;
  --brand-soft: #ebf1fe;
  --danger: #d14343;
  --danger-soft: #fdecec;
  --ok: #1f7a4c;
  --ok-soft: #e8f6ef;
  --shadow: 0 1px 2px rgba(30, 35, 48, 0.04);
  --shadow-panel: -4px 0 24px rgba(30, 35, 48, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* —— App shell —— */
.app-shell {
  min-height: 100vh;
}
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 0.75rem;
  background: #fff;
  border-right: 1px solid var(--line);
  z-index: 40;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.brand {
  display: block;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  padding: 0.55rem 0.7rem;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.92rem;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}
.side-nav a:hover {
  background: var(--bg-soft);
  color: var(--ink);
  text-decoration: none;
}
.side-nav a.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.nav-ico {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.9;
}
.sidebar-foot {
  padding: 0.5rem 0.35rem 0.25rem;
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 0.45rem;
  margin-top: auto;
  flex-shrink: 0;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.35rem 0.35rem;
}
.user-avatar {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 700;
}
.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-link {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.2rem 0.35rem;
  text-decoration: none;
}
.logout-link:hover { color: var(--ink); }

.main {
  min-width: 0;
  max-width: 100%;
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  padding: 1.25rem 1.5rem 2.5rem;
  overflow-x: hidden;
}
.main > .stack {
  min-width: 0;
  max-width: 100%;
}

.wrap { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; }

/* Legacy topbar (unused in shell, keep safe) */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0;
}
.nav { display: flex; gap: 0.55rem; align-items: center; flex-wrap: wrap; }
.nav a, .nav span { color: var(--muted); font-size: 0.95rem; }
.nav a {
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
}
.nav a.active {
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 600;
}
.nav .user { color: var(--ink); font-weight: 600; }

/* —— Surfaces —— */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
}

h1, h2, h3 {
  margin: 0 0 0.4rem;
  letter-spacing: -0.03em;
  font-weight: 700;
}
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 0.9rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: end; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.page-head p { margin: 0; }

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  flex: 1;
  min-width: 160px;
}
input, select, textarea, button {
  font: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #a8c0f5;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}
textarea { min-height: 90px; resize: vertical; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--brand);
  color: #fff;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
button:hover, .btn:hover { background: var(--brand-hover); text-decoration: none; }
button[hidden],
.btn[hidden],
[hidden] {
  display: none !important;
}
button.group-toggle:hover,
button.group-toggle:focus,
button.group-toggle:focus-visible,
button.linkish:hover,
button.linkish:focus {
  background: transparent;
  color: inherit;
  box-shadow: none;
}
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 500;
}
.btn-secondary:hover { background: var(--bg-soft); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
}
.btn-ghost:hover {
  background: var(--bg-soft);
  color: var(--ink);
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
}
.btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.flash {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  font-size: 0.9rem;
}
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: #c5e6d4; }
.flash.error { background: var(--danger-soft); color: var(--danger); border-color: #f0c2c2; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 420px at 15% -10%, #dce8ff 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, #e8eef8 0%, transparent 50%),
    var(--bg);
}
.login-card { width: min(400px, 100%); }

/* —— Task list (ClickUp-like) —— */
.list-shell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
.completed-section {
  margin-top: 0.5rem;
}
.list-shell-completed {
  box-shadow: none;
  opacity: 0.92;
}
.list-shell-completed .task-row td {
  color: var(--muted, #667085);
}
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  background: #fafbfc;
}
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}
table.task-list {
  width: max-content;
  min-width: 100%;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  font-size: 0.9rem;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbfc;
  position: sticky;
  top: 0;
  z-index: 1;
}
.task-list tbody tr.task-row:hover td {
  background: #f7f8fb;
}
.task-row.is-open td,
tr.row-active td {
  background: var(--brand-soft) !important;
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
}
.badge.admin { background: var(--brand-soft); color: var(--brand); }
.badge.off { background: var(--danger-soft); color: var(--danger); }

.perms-grid { display: grid; gap: 0.6rem; }
.perm-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.actions {
  display: flex;
  gap: 0.25rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  opacity: 0.55;
  transition: opacity 0.12s ease;
}
.task-row:hover .actions,
.task-row.is-open .actions {
  opacity: 1;
}
.order-form { margin: 0; }

button.linkish,
.linkish {
  display: inline;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.check-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.check-row input { width: auto; margin: 0; }

.password-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.password-wrap > input {
  width: 100%;
  padding-right: 2.75rem !important;
}
.password-eye {
  all: unset;
  position: absolute !important;
  right: 0.55rem !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 1.5rem !important;
  height: 1.5rem !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--muted) !important;
  box-shadow: none !important;
  cursor: pointer !important;
  line-height: 0 !important;
  z-index: 2 !important;
}
.password-eye:hover {
  color: var(--ink) !important;
  background: transparent !important;
}
.password-eye svg {
  display: block;
  pointer-events: none;
}

.inline-edit { margin: 0; }
.cell-input {
  width: 100%;
  min-width: 7rem;
  padding: 0.35rem 0.45rem !important;
  border-radius: 6px !important;
  border-color: transparent !important;
  font: inherit;
  background: transparent;
  box-shadow: none !important;
}
.cell-input:hover {
  background: #fff;
  border-color: var(--line) !important;
}
.cell-input:focus {
  background: #fff;
  border-color: #a8c0f5 !important;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12) !important;
}
.cell-title {
  min-width: 8rem;
  max-width: 14rem;
  width: 14rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-list td .linkish {
  display: inline-block;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.task-list td .inline-edit {
  max-width: 14rem;
}
.task-list .cell-input:not(.order-input):not(select) {
  max-width: 14rem;
}
.order-input {
  width: 3.4rem;
  min-width: 3.4rem;
  padding: 0.3rem 0.35rem !important;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
}
td .inline-edit select.cell-input {
  min-width: 7.5rem;
}

.layout-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  margin: 0;
}
.layout-group {
  display: grid;
  gap: 0.25rem;
  min-width: 180px;
  flex: 0 1 220px;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}
.layout-note { padding: 0.15rem 0; margin: 0; }

tr.group-row td {
  background: #f3f5f8 !important;
  border-bottom: 1px solid var(--line);
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}
tr.group-row:hover td { background: #eef1f6 !important; }
tr.group-row.is-collapsed td { border-bottom-color: var(--line); }
.group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 0;
  background: transparent;
  padding: 0.25rem 0.15rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  max-width: 100%;
}
.group-toggle:hover .group-label { color: var(--ink); }
.group-toggle:hover { background: transparent; }
.add-task-prompt td {
  padding: 0.45rem 0.75rem;
  background: transparent !important;
  border-bottom: 0;
}
.add-task-prompt .add-task-open {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0;
}
.add-task-prompt .add-task-open:hover {
  color: var(--ink);
  text-decoration: underline;
}
.add-task-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  opacity: 1;
}
.add-task-actions .add-task-cancel {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  padding: 0;
}
.add-task-actions .add-task-cancel:hover {
  color: var(--ink);
  text-decoration: underline;
}
.group-chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  margin-right: 0.15rem;
}
.group-toggle[aria-expanded="false"] .group-chevron {
  transform: rotate(-45deg);
}
.group-label {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.88rem;
}
.group-count {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0.05rem 0.4rem;
  border-radius: 6px;
  background: #e4e8ef;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(30, 35, 48, 0.4);
  overflow: auto;
}
.modal-card {
  width: min(720px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(30, 35, 48, 0.14);
  padding: 1.25rem;
}

.notes-card { min-height: 0; }
.notes-card.is-editing { min-height: 280px; }
.notes-pencil {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
}
.note-view h1 { font-size: 1.45rem; }
.notes-editor-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.notes-editor-wrap .ql-toolbar.ql-snow {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}
.notes-editor-wrap .ql-container.ql-snow {
  border: 0;
  font-family: var(--font);
  font-size: 0.95rem;
  min-height: 280px;
}
.notes-editor-wrap .ql-editor {
  min-height: 280px;
  line-height: 1.55;
  color: var(--ink);
}
.notes-editor-wrap .ql-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.5rem 0;
}
.notes-content,
.readonly-notes { line-height: 1.55; }
.notes-content img,
.readonly-notes img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
.notes-content a,
.readonly-notes a { color: var(--brand); }
.readonly { color: var(--muted); }
.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}

/* Side panel */
body.drawer-open { overflow: hidden; }
.task-drawer[hidden] { display: none !important; }
.task-drawer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: flex-end;
}
.task-drawer-scrim {
  position: absolute;
  inset: 0;
  z-index: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(30, 35, 48, 0.35) !important;
  cursor: pointer;
  box-shadow: none !important;
  color: transparent !important;
}
.task-drawer-panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.18s ease-out;
}
@keyframes drawer-in {
  from { transform: translateX(12px); opacity: 0.85; }
  to { transform: translateX(0); opacity: 1; }
}
.task-drawer-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
  background: #fafbfc;
  flex-shrink: 0;
}
.task-drawer-panel iframe {
  border: 0;
  width: 100%;
  flex: 1;
  background: #fff;
}
body.embed-mode {
  background: #fff;
  margin: 0;
}
.embed-wrap {
  padding: 1rem 1.15rem 2rem;
  max-width: none;
}
.embed-mode .card {
  box-shadow: none;
  border: 0;
  padding: 0;
  background: transparent;
}
.embed-mode .flash {
  margin: 0.75rem 1rem 0;
}
.notes-content a,
.readonly.linkify a,
.linkify a,
.content-preview a {
  color: var(--brand);
  text-decoration: underline;
  word-break: break-all;
}
.content-preview {
  margin-bottom: 0.55rem;
  padding: 0.55rem 0.65rem;
  background: #f7f8fb;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.92rem;
  line-height: 1.45;
}
.embed-save-bar {
  position: sticky;
  bottom: 0;
  padding: 0.75rem 0 0.25rem;
  background: linear-gradient(to top, #fff 70%, rgba(255, 255, 255, 0));
  z-index: 2;
}
.embed-save-bar button {
  width: 100%;
}
.add-task-row td {
  padding: 0.4rem 0.75rem;
  background: #fafbfc !important;
  border-bottom: 0;
  vertical-align: middle;
}
.add-task-row .cell-input,
.add-task-row .date-trigger {
  background: #fff;
  border-color: var(--line) !important;
}
.add-task-row .add-task-title {
  min-width: 10rem;
  font-weight: 500;
}
.add-task-row .add-task-title::placeholder {
  color: var(--muted);
  font-weight: 500;
}
.add-task-actions .add-task-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin: 0;
  justify-content: flex-end;
}
.add-task-row .add-task-submit {
  opacity: 1;
  white-space: nowrap;
}
.add-task-form {
  display: inline;
}
button.linkish {
  all: unset;
  cursor: pointer;
  color: inherit;
  font: inherit;
  max-width: 100%;
}
button.linkish:hover,
button.linkish:focus-visible {
  color: var(--brand);
}
.notes-preview {
  display: inline-block;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  color: var(--muted);
  font-weight: 500;
}

.storage-hero {
  padding: 1rem 0 0.25rem;
}
.storage-total {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--ink);
}
.storage-bar {
  display: flex;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-soft);
}
.storage-seg { display: block; height: 100%; min-width: 2px; }
.storage-seg-code { background: #6b7c93; }
.storage-seg-uploads { background: var(--brand); }
.storage-seg-database { background: #1f7a4c; }
.storage-legend {
  display: grid;
  gap: 0.45rem;
}
.storage-legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.88rem;
}
.storage-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 3px;
  display: inline-block;
}
.storage-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.75rem;
}
.storage-stat {
  display: grid;
  gap: 0.2rem;
  padding: 0.7rem 0.8rem;
  background: var(--bg-soft);
  border-radius: 8px;
}
.storage-stat strong {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.storage-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.storage-details[open] summary {
  margin-bottom: 0.65rem;
  color: var(--ink);
}

/* Collapsible section (Add member, etc.) */
.fold-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
  padding: 0.15rem 0.85rem 0.15rem;
}
.fold-panel > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 0.1rem;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  user-select: none;
}
.fold-panel > summary::-webkit-details-marker { display: none; }
.fold-panel > summary::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.fold-panel[open] > summary::before {
  transform: rotate(45deg);
}
.fold-panel[open] > summary {
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.85rem;
}
.fold-panel[open] {
  padding-bottom: 0.85rem;
}

/* Dashboard / billing */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}
.dash-stat {
  display: grid;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.dash-stat strong {
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  font-weight: 700;
}
.dash-stat-money strong {
  color: var(--ok);
}
.money-input {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 12rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.15rem 0.45rem 0.15rem 0.55rem;
}
.dash-table select.rate-currency {
  min-width: 6.5rem;
  max-width: 8rem;
}

/* Clients */
.client-location {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.35rem 0.85rem 0.85rem;
}
.client-location > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.15rem;
  font-weight: 700;
}
.client-location > summary::-webkit-details-marker { display: none; }
.client-location-name { letter-spacing: -0.02em; }
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}
.client-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.client-card:hover {
  border-color: #a8c0f5;
  background: #fff;
  text-decoration: none;
  color: inherit;
}
.client-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}
.client-card-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--brand);
  white-space: nowrap;
}
.client-card-meta {
  font-size: 0.82rem;
}
.client-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
  margin-top: 0.15rem;
}
.client-clocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}
.client-clock-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.client-clock-time {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  margin-top: 0.2rem;
}
.client-clock-date {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.15rem;
}
.client-clock-card.is-local .client-clock-time { color: var(--brand); }
.client-clock-card.is-rate .client-clock-time { color: var(--ok); font-size: 1.45rem; }

.money-input:focus-within {
  border-color: #a8c0f5;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}
.money-prefix {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}
.money-suffix {
  font-size: 0.78rem;
  white-space: nowrap;
}
.money-input input {
  border: 0 !important;
  box-shadow: none !important;
  padding: 0.4rem 0.2rem !important;
  min-width: 0;
  width: 5.5rem;
  background: transparent !important;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.money-value {
  font-variant-numeric: tabular-nums;
  color: var(--ok);
}
.dash-table th:nth-child(3),
.dash-table td:nth-child(3),
.dash-table th:nth-child(4),
.dash-table td:nth-child(4),
.dash-table th:nth-child(5),
.dash-table td:nth-child(5) {
  white-space: nowrap;
}

/* Custom date picker */
.date-wrap {
  position: relative;
  display: block;
  min-width: 8.5rem;
}
.date-trigger {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  color: var(--ink);
}
.date-trigger.is-empty {
  color: var(--muted);
}
.date-trigger:hover {
  background: #fff;
  border-color: var(--line);
}
.date-wrap .date-trigger.cell-input:focus,
.date-trigger:focus-visible {
  outline: none;
  background: #fff;
  border-color: #a8c0f5;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}
label .date-wrap .date-trigger {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
}
.dp-popover {
  position: absolute;
  z-index: 120;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(30, 35, 48, 0.14);
  padding: 0.7rem;
  font-family: var(--font);
}
.dp-popover[hidden] { display: none !important; }
.dp-shortcuts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.dp-shortcuts button {
  background: var(--bg-soft);
  color: var(--ink);
  border: 0;
  border-radius: 7px;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.dp-shortcuts button:hover {
  background: var(--brand-soft);
  color: var(--brand);
}
.dp-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}
.dp-month-label {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.02em;
}
.dp-nav {
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.dp-nav:hover { background: var(--bg-soft); }
.dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.15rem;
  margin-bottom: 0.2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
}
.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.15rem;
}
.dp-day {
  aspect-ratio: 1;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.dp-day:hover { background: var(--bg-soft); }
.dp-day.is-muted { color: #b0b6c3; }
.dp-day.is-today {
  box-shadow: inset 0 0 0 1px var(--brand);
  color: var(--brand);
  font-weight: 700;
}
.dp-day.is-selected {
  background: var(--brand);
  color: #fff;
  box-shadow: none;
}
.dp-day.is-selected:hover { background: var(--brand-hover); }
.dp-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--line-soft);
}
.dp-foot button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
}
.dp-foot button:hover { color: var(--ink); }

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }
  .sidebar {
    position: relative;
    left: auto;
    top: auto;
    bottom: auto;
    width: auto;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    overflow: visible;
  }
  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
  }
  .sidebar-foot {
    border-top: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0;
    margin-top: 0;
    margin-left: auto;
  }
  .main {
    margin-left: 0;
    width: 100%;
    padding: 1rem;
  }
}

@media (max-width: 700px) {
  .perm-row { grid-template-columns: 1fr; }
  .task-drawer-panel { width: 100%; }
  .actions { opacity: 1; }
}
