:root {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #111827;
  --surface-soft: #162033;
  --surface-strong: #0b1120;
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, .18);
  --blue: #38bdf8;
  --green: #22c55e;
  --yellow: #facc15;
  --red: #fb7185;
  --shadow: 0 24px 70px rgba(2, 6, 23, .42);
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 82px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button, select, textarea { font: inherit; }

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 12%, rgba(56, 189, 248, .16), transparent 30%),
    radial-gradient(circle at 78% 20%, rgba(34, 197, 94, .12), transparent 26%),
    var(--bg);
}

.login-shell { width: min(440px, 100%); }

.login-card {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 24, 39, .88);
  box-shadow: var(--shadow);
}

.brand-block {
  text-align: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 70px;
  height: 70px;
  margin: 0 auto 16px;
  border: 1px solid rgba(56, 189, 248, .42);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: rgba(56, 189, 248, .09);
  font-size: 28px;
  font-weight: 900;
}

.brand-mark img {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.login-logo {
  width: 118px;
  height: 118px;
  margin: 0 auto 16px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.brand-block h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.brand-block p {
  margin: 10px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.login-form input,
.modal input,
.modal textarea,
.modal select,
.form-panel input,
.form-panel textarea,
.form-panel select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #0b1120;
  outline: none;
}

.modal textarea {
  min-height: 120px;
  padding: 12px 14px;
  resize: vertical;
}

.form-panel textarea {
  min-height: 180px;
  padding: 12px 14px;
  resize: vertical;
}

.login-form input:focus,
.modal input:focus,
.modal textarea:focus,
.modal select:focus,
.form-panel input:focus,
.form-panel textarea:focus,
.form-panel select:focus {
  border-color: rgba(56, 189, 248, .7);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, .12);
}

.login-form button,
.quick-link,
.primary-action,
.secondary-action,
.danger-action,
.add-card-button {
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  color: #06111a;
  background: var(--blue);
  font-weight: 900;
  cursor: pointer;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.secondary-action,
.add-card-button {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.07);
}

.danger-action {
  color: #fecdd3;
  border: 1px solid rgba(251, 113, 133, .36);
  background: rgba(251, 113, 133, .12);
}

.login-form button { margin-top: 10px; }

.alert {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(251, 113, 133, .36);
  border-radius: 8px;
  color: #fecdd3;
  background: rgba(251, 113, 133, .1);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  transition: grid-template-columns .18s ease;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: var(--surface-strong);
  overflow: hidden;
  transition: width .18s ease, transform .18s ease, padding .18s ease;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  border: 0;
  background: rgba(2, 6, 23, .66);
  backdrop-filter: blur(4px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  min-width: 0;
}

.sidebar-brand .brand-mark {
  width: 44px;
  height: 44px;
  margin: 0;
  font-size: 18px;
  padding: 0;
  background: #ffffff;
}

.sidebar-brand-toggle {
  flex: 0 0 44px;
  cursor: pointer;
}

.sidebar-brand-toggle:hover {
  border-color: rgba(56, 189, 248, .72);
  background: #ffffff;
}

.sidebar-brand strong { display: block; font-size: 18px; }
.sidebar-brand span { display: block; color: var(--muted); font-size: 12px; }

.sidebar-brand > div:last-of-type {
  min-width: 0;
}

body.sidebar-collapsed .sidebar {
  padding-inline: 14px;
}

body.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}

body.sidebar-collapsed .sidebar-brand > div:not(.brand-mark),
body.sidebar-collapsed .nav-label {
  display: none;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  min-width: 0;
}

.nav-list a.active,
.nav-list a:hover {
  color: var(--text);
  background: rgba(56, 189, 248, .1);
}

.nav-icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  font-size: 16px;
  font-weight: 900;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.sidebar-collapsed .nav-list a {
  justify-content: center;
  padding-inline: 8px;
}

.main-area { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, .82);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.topbar a {
  color: var(--muted);
  font-weight: 800;
}

.content {
  width: min(1360px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.welcome {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 22px;
}

.welcome h2 {
  margin: 0;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

.welcome p {
  margin: 10px 0 0;
  color: var(--muted);
}

.summary-grid,
.quick-grid,
.knowledge-grid {
  display: grid;
  gap: 14px;
}

.summary-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.summary-card,
.panel,
.trello-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-card {
  min-height: 134px;
  padding: 20px;
}

.summary-card span {
  color: var(--muted);
  font-size: 14px;
}

.summary-card strong {
  display: block;
  margin-top: 18px;
  font-size: 36px;
  line-height: 1;
}

.section { margin-top: 28px; }

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

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

.section-title span {
  color: var(--muted);
  font-size: 14px;
}

.quick-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.quick-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 0 14px;
}

.board-page {
  min-height: calc(100vh - 144px);
}

.board-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.board-toolbar h2 {
  margin: 0;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

.board-toolbar p {
  margin: 10px 0 0;
  color: var(--muted);
}

.board-message {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(56, 189, 248, .32);
  border-radius: 8px;
  color: #dbeafe;
  background: rgba(56, 189, 248, .1);
}

.board-message[data-tone="error"] {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, .36);
  background: rgba(251, 113, 133, .1);
}

.trello-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.trello-board-full {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 230px);
}

.column {
  min-height: 310px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 24, 39, .68);
}

.trello-list {
  flex: 0 0 clamp(280px, 30vw, 330px);
  max-height: calc(100vh - 230px);
  display: flex;
  flex-direction: column;
}

.column h4 {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
}

.list-header {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  cursor: grab;
}

.list-actions {
  display: flex;
  gap: 8px;
}

.list-actions button,
.card-edit {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,.05);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.card-dropzone {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  padding-right: 2px;
}

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

.trello-card {
  position: relative;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface-soft);
  cursor: grab;
}

.trello-card.dragging,
.trello-list.dragging {
  opacity: .55;
}

.card-edit {
  position: absolute;
  top: 10px;
  right: 10px;
  opacity: 0;
  transition: opacity .16s ease;
}

.trello-card:hover .card-edit,
.trello-card:focus-within .card-edit {
  opacity: 1;
}

.trello-card strong {
  display: block;
  padding-right: 58px;
  margin-bottom: 6px;
}

.trello-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(56, 189, 248, .12);
  font-size: 12px;
}

.empty-state {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

.add-card-button {
  width: 100%;
  margin-top: 12px;
}

.modal {
  width: min(560px, calc(100% - 28px));
  border: 0;
  padding: 0;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
}

.wide-modal {
  width: min(820px, calc(100% - 28px));
}

.modal::backdrop {
  background: rgba(2, 6, 23, .72);
  backdrop-filter: blur(6px);
}

.modal-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.modal-card h3 {
  margin: 0;
  font-size: 22px;
}

.modal-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

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

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-spacer { flex: 1; }

.compact-action {
  min-height: 40px;
  padding: 0 12px;
}

.notes-app {
  min-height: calc(100vh - 144px);
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 16px;
}

.notes-folders,
.notes-main,
.note-list-panel,
.note-reader {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.notes-folders {
  min-height: calc(100vh - 144px);
  padding: 16px;
}

.notes-side-head,
.notes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notes-side-head {
  margin-bottom: 14px;
}

.notes-side-head h2,
.notes-toolbar h3 {
  margin: 0;
  line-height: 1;
  letter-spacing: 0;
}

.notes-side-head h2 {
  font-size: 32px;
}

.notes-side-head p,
.notes-toolbar span {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.notes-message {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, .32);
  border-radius: 8px;
  color: #dbeafe;
  background: rgba(56, 189, 248, .1);
}

.notes-message[data-tone="error"] {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, .36);
  background: rgba(251, 113, 133, .1);
}

.folder-list {
  display: grid;
  gap: 8px;
}

.folder-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255,255,255,.03);
}

.folder-item.active {
  border-color: rgba(56, 189, 248, .34);
  background: rgba(56, 189, 248, .1);
}

.folder-item button {
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.folder-item strong,
.folder-item span {
  display: block;
}

.folder-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.folder-edit {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line) !important;
  border-radius: 8px;
  color: var(--muted) !important;
  font-size: 12px;
  font-weight: 800;
}

.notes-main {
  min-width: 0;
  padding: 16px;
}

.notes-toolbar {
  min-height: 56px;
  margin-bottom: 14px;
}

.notes-grid {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 14px;
  min-height: calc(100vh - 230px);
}

.note-list-panel {
  padding: 10px;
  overflow-y: auto;
}

.note-row {
  width: 100%;
  display: block;
  margin-bottom: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255,255,255,.03);
  cursor: pointer;
  text-align: left;
}

.note-row.active,
.note-row:hover {
  border-color: rgba(56, 189, 248, .42);
  background: rgba(56, 189, 248, .09);
}

.note-row strong,
.note-row span {
  display: block;
}

.note-row span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.note-reader {
  min-width: 0;
  padding: 26px;
  overflow-y: auto;
}

.reader-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.reader-head h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

.reader-head span {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.reader-content {
  color: #dbe5ef;
  font-size: 18px;
  line-height: 1.75;
  white-space: normal;
}

.module-page {
  display: grid;
  gap: 24px;
}

.module-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.module-hero h2 {
  margin: 0;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

.module-hero p {
  margin: 10px 0 0;
  color: var(--muted);
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.module-card,
.data-panel,
.settings-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.module-card {
  min-height: 150px;
  padding: 20px;
}

.module-card span,
.module-card p,
.data-row span,
.settings-row span {
  color: var(--muted);
}

.module-card strong {
  display: block;
  margin-top: 14px;
  font-size: 28px;
  line-height: 1;
}

.module-card p {
  margin: 12px 0 0;
  font-size: 14px;
}

.data-panel {
  padding: 12px;
}

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

.data-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(200px, .8fr) minmax(170px, .7fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
}

.data-row strong,
.data-row span {
  display: block;
}

.settings-row {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.client-form,
.form-panel {
  display: grid;
  gap: 16px;
}

.form-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.form-panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.row-actions form {
  margin: 0;
}

.row-actions .secondary-action,
.row-actions .danger-action {
  min-height: 38px;
  padding-inline: 12px;
}

.inventory-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, .35fr) minmax(180px, .35fr);
  gap: 12px;
  margin-bottom: 14px;
}

.inventory-filters input,
.inventory-filters select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #0b1120;
  outline: none;
}

.inventory-latest {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.inventory-table {
  display: grid;
  gap: 8px;
}

.inventory-head,
.inventory-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(120px, .7fr) minmax(110px, .55fr) minmax(120px, .7fr) minmax(120px, .7fr) minmax(110px, .55fr) minmax(230px, .9fr);
  gap: 12px;
  align-items: center;
}

.inventory-head {
  padding: 8px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.inventory-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
}

.inventory-row.low-stock {
  border-color: rgba(250, 204, 21, .4);
  background: rgba(250, 204, 21, .06);
}

.inventory-row span {
  color: var(--muted);
}

.detail-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.detail-grid div,
.detail-notes {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
}

.detail-grid span,
.detail-notes span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.detail-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}

.detail-notes p {
  margin: 10px 0 0;
  color: #dbe5ef;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.pagination a {
  min-width: 38px;
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.pagination a.active {
  color: #06111a;
  border-color: var(--blue);
  background: var(--blue);
}

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.module-tabs a {
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.module-tabs a.active,
.module-tabs a:hover {
  color: var(--text);
  background: rgba(56, 189, 248, .1);
}

.finance-chart,
.finance-table {
  display: grid;
  gap: 8px;
}

.chart-row {
  display: grid;
  grid-template-columns: 100px minmax(120px, 1fr) minmax(120px, 1fr) minmax(140px, .6fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.chart-row div {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
}

.chart-row span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.chart-row .expense-bar {
  background: var(--red);
}

.chart-row em {
  color: var(--muted);
  font-style: normal;
}

.finance-head,
.finance-row {
  display: grid;
  grid-template-columns: minmax(95px, .55fr) minmax(180px, 1.2fr) minmax(130px, .7fr) minmax(150px, .8fr) minmax(110px, .55fr) minmax(100px, .5fr) minmax(190px, .9fr);
  gap: 12px;
  align-items: center;
}

.finance-head {
  padding: 8px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.finance-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
}

.finance-row span {
  color: var(--muted);
}

.finance-category-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.finance-category-row input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #0b1120;
}

.finance-integration {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
}

.finance-integration summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
}

.finance-integration .form-grid {
  margin-top: 14px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 10px;
}

.checkbox-label input {
  width: auto;
  min-height: auto;
}

.primary-action:disabled {
  opacity: .58;
  cursor: not-allowed;
}

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

.panel {
  min-height: 260px;
  padding: 20px;
}

.note-list {
  display: grid;
  gap: 12px;
}

.note-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
}

.note-item strong { display: block; }
.note-item p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.knowledge-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.knowledge-tags span {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,.03);
}

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform .18s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  body.sidebar-collapsed .sidebar-brand > div:not(.brand-mark),
  body.sidebar-collapsed .nav-label {
    display: block;
  }
  body.sidebar-collapsed .nav-list a {
    justify-content: flex-start;
    padding-inline: 12px;
  }
  .knowledge-grid { grid-template-columns: 1fr; }
  .board-toolbar { align-items: stretch; flex-direction: column; }
  .notes-app { grid-template-columns: 1fr; }
  .notes-folders { min-height: auto; }
  .notes-grid { grid-template-columns: 1fr; }
  .note-list-panel { max-height: 320px; }
  .content { width: min(100% - 32px, 1360px); }
  .module-hero { align-items: stretch; flex-direction: column; }
  .data-row { grid-template-columns: 1fr; }
  .inventory-filters { grid-template-columns: 1fr; }
  .inventory-head { display: none; }
  .inventory-row { grid-template-columns: 1fr; }
  .finance-head { display: none; }
  .finance-row,
  .chart-row,
  .finance-category-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .content {
    width: min(100% - 24px, 1360px);
    padding-top: 18px;
  }
  .topbar {
    min-height: 64px;
    padding: 12px;
  }
  .topbar p { display: none; }
  .welcome { display: block; }
  .login-card { padding: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .trello-list { flex-basis: min(84vw, 300px); }
  .board-toolbar h2,
  .notes-side-head h2,
  .reader-head h1,
  .welcome h2 {
    font-size: 30px;
  }
  .modal-card { padding: 18px; }
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .modal-spacer { display: none; }
  .notes-main,
  .notes-folders,
  .note-reader { padding: 14px; }
  .notes-toolbar,
  .reader-head { align-items: stretch; flex-direction: column; }
  .module-hero h2 { font-size: 30px; }
}

/* Responsive standardization layer */
html,
body {
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

input,
select,
textarea,
button,
a {
  min-width: 0;
}

.topbar > div,
.module-hero > div,
.section-title > div,
.reader-head > div,
.notes-toolbar > div,
.notes-side-head > div {
  min-width: 0;
}

.topbar h1,
.module-hero h2,
.section-title h3,
.reader-head h1,
.notes-toolbar h3,
.notes-side-head h2 {
  overflow-wrap: anywhere;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
}

.inventory-filters {
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
}

.data-panel,
.finance-table,
.inventory-table {
  min-width: 0;
  overflow-x: auto;
}

.finance-head,
.finance-row {
  min-width: 980px;
}

.inventory-head,
.inventory-row {
  min-width: 1040px;
}

.data-row {
  min-width: 860px;
}

.module-tabs {
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: thin;
}

.module-tabs a {
  flex: 0 0 auto;
  white-space: nowrap;
}

.primary-action,
.secondary-action,
.danger-action,
.quick-link,
.add-card-button {
  text-align: center;
  white-space: normal;
}

@media (max-width: 1280px) {
  :root {
    --sidebar-width: 260px;
  }

  .content {
    width: min(100% - 32px, 1180px);
  }

  .module-card {
    min-height: 132px;
  }

  .module-card strong {
    font-size: 24px;
  }

  .summary-card strong {
    font-size: 32px;
  }
}

@media (max-width: 900px) {
  .content {
    width: min(100% - 28px, 1000px);
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }

  .welcome,
  .module-hero,
  .section-title,
  .reader-head,
  .notes-toolbar,
  .notes-side-head,
  .board-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .data-row,
  .finance-head,
  .finance-row,
  .inventory-head,
  .inventory-row {
    min-width: 0;
  }

  .data-row,
  .finance-row,
  .inventory-row,
  .chart-row,
  .finance-category-row {
    grid-template-columns: 1fr;
  }

  .finance-head,
  .inventory-head {
    display: none;
  }

  .trello-board-full {
    min-height: 520px;
  }

  .trello-list {
    flex-basis: min(78vw, 320px);
    max-height: 70vh;
  }
}

@media (max-width: 720px) {
  .login-page {
    padding: 16px;
  }

  .login-card,
  .form-panel,
  .detail-panel,
  .panel,
  .notes-main,
  .notes-folders,
  .note-reader,
  .data-panel {
    padding: 14px;
  }

  .module-page {
    gap: 18px;
  }

  .module-grid,
  .summary-grid,
  .quick-grid,
  .knowledge-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .module-tabs {
    margin-inline: -2px;
    padding: 6px;
  }

  .module-tabs a {
    min-height: 38px;
    padding-inline: 12px;
  }

  .modal {
    width: min(100% - 20px, 560px);
  }

  .wide-modal {
    width: min(100% - 20px, 820px);
  }

  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-actions .primary-action,
  .modal-actions .secondary-action,
  .modal-actions .danger-action,
  .row-actions .primary-action,
  .row-actions .secondary-action,
  .row-actions .danger-action,
  .row-actions form,
  .row-actions button {
    width: 100%;
  }

  .modal-spacer {
    display: none;
  }

  .reader-content {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .content {
    width: min(100% - 20px, 1000px);
    padding: 16px 0 32px;
  }

  .topbar {
    min-height: 58px;
    padding: 10px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .sidebar {
    width: min(88vw, 300px);
    padding: 18px 14px;
  }

  .sidebar-brand {
    margin-bottom: 22px;
  }

  .nav-list a {
    min-height: 42px;
  }

  .brand-block h1,
  .welcome h2,
  .module-hero h2,
  .board-toolbar h2,
  .notes-side-head h2,
  .reader-head h1 {
    font-size: 28px;
  }

  .summary-card,
  .module-card {
    min-height: auto;
    padding: 16px;
  }

  .summary-card strong,
  .module-card strong {
    font-size: 28px;
  }

  .trello-list {
    flex-basis: min(86vw, 290px);
  }

  .note-list-panel {
    max-height: 280px;
  }
}
