@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;600;700;800;900&display=swap');

:root {
  --sage: #526d60;
  --sage-dark: #293f38;
  --sage-soft: #6f8579;
  --salmon: #da9482;
  --salmon-dark: #bf7566;
  --paper: #f6f7f4;
  --paper-2: #eef1ec;
  --ink: #24332e;
  --muted: #748078;
  --line: rgba(36, 51, 46, 0.12);
  --white: #ffffff;
  --danger: #b85f52;
  --shadow: 0 24px 60px rgba(25, 38, 33, 0.16);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Nunito Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--sage);
  color: var(--ink);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  background: linear-gradient(180deg, var(--sage-dark), var(--sage));
  color: var(--paper);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 40px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: var(--salmon);
  color: var(--paper);
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  opacity: 0.72;
  margin-top: 4px;
}

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

.nav a {
  padding: 13px 15px;
  border-radius: 999px;
  color: rgba(246, 247, 244, 0.82);
  font-weight: 800;
}

.nav a:hover,
.nav a.active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--white);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
}

.sidebar-footer a {
  color: var(--salmon);
  font-weight: 900;
}

.main-content {
  background: var(--paper);
  min-height: 100vh;
  border-top-left-radius: 38px;
  padding: 34px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.topbar h1,
.login-card h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  letter-spacing: -0.055em;
  line-height: 0.95;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--salmon-dark);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  border: 0;
  min-height: 42px;
  padding: 12px 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn:hover { transform: translateY(-1px); }

.btn.primary {
  background: var(--salmon);
  color: var(--paper);
  box-shadow: 0 12px 24px rgba(218, 148, 130, 0.35);
}

.btn.soft {
  background: var(--paper-2);
  color: var(--sage-dark);
}

.btn.full { width: 100%; }

.hero-card {
  position: relative;
  overflow: hidden;
  min-height: 260px;
  border-radius: var(--radius-xl);
  background: var(--sage);
  color: var(--paper);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 24px;
  padding: clamp(26px, 4vw, 52px);
  margin-bottom: 24px;
}

.hero-number {
  font-size: clamp(8rem, 18vw, 16rem);
  font-weight: 900;
  line-height: 0.72;
  letter-spacing: -0.08em;
  color: var(--salmon);
}

.hero-text h2 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(2rem, 5vw, 4.7rem);
  line-height: 0.96;
  letter-spacing: -0.06em;
  font-weight: 900;
}

.hero-text p:last-child {
  max-width: 520px;
  font-weight: 800;
  color: rgba(246, 247, 244, 0.82);
  font-size: 1.05rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.compact-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(25, 38, 33, 0.06);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 10px;
}

.stat-card strong {
  display: block;
  font-size: clamp(1.45rem, 2.4vw, 2.3rem);
  letter-spacing: -0.055em;
  line-height: 1;
}

.stat-card.warning strong,
.danger-text { color: var(--danger); }

.content-grid.two {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel,
.profile-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 24px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(25, 38, 33, 0.06);
}

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

.panel-header h3 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.panel-header a,
.panel-header span {
  color: var(--salmon-dark);
  font-weight: 900;
}

.client-mini-list {
  display: grid;
  gap: 10px;
}

.client-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: var(--paper);
}

.client-mini strong,
.client-mini small {
  display: block;
}

.client-mini small {
  color: var(--muted);
  margin-top: 3px;
  font-weight: 700;
}

.avatar,
.profile-logo {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: var(--sage);
  color: var(--paper);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.timeline {
  position: relative;
  display: grid;
  gap: 14px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
  align-items: start;
}

.timeline-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--salmon);
  margin-top: 7px;
  box-shadow: 0 0 0 6px rgba(218, 148, 130, 0.14);
}

.timeline time {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.timeline p {
  margin: 3px 0 0;
  font-weight: 700;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.toast-stack {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 1000;
  width: min(420px, calc(100vw - 44px));
  margin: 0;
  pointer-events: none;
}

.flash-stack.compact {
  position: static;
  width: auto;
  margin: 18px 0;
  pointer-events: auto;
}

.flash {
  padding: 13px 16px;
  border-radius: 16px;
  background: var(--paper-2);
  font-weight: 800;
}

.toast-popup {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: toastIn 220ms ease-out both;
}

.toast-icon {
  width: 34px;
  height: 34px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.58);
}

.flash.success { background: rgba(82, 109, 96, 0.18); color: var(--sage-dark); border-color: rgba(82, 109, 96, 0.24); }
.flash.danger { background: rgba(184, 95, 82, 0.18); color: var(--danger); border-color: rgba(184, 95, 82, 0.25); }
.flash.warning { background: rgba(218, 148, 130, 0.2); color: var(--salmon-dark); border-color: rgba(218, 148, 130, 0.28); }
.flash.info { background: rgba(246, 241, 234, 0.94); color: var(--ink); border-color: var(--line); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px auto;
  gap: 10px;
  margin-bottom: 18px;
}

.filters.slim { grid-template-columns: 260px auto; }

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

.form-grid.single { grid-template-columns: 1fr; }

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--salmon);
  box-shadow: 0 0 0 4px rgba(218, 148, 130, 0.16);
  background: var(--white);
}

.span-2 { grid-column: span 2; }

.form-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

.mini-table table { min-width: 680px; }

th,
td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.table-link {
  color: var(--sage-dark);
  font-weight: 900;
}

.money-cell {
  font-weight: 900;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(82, 109, 96, 0.12);
  color: var(--sage-dark);
  font-weight: 900;
  font-size: 0.82rem;
  white-space: nowrap;
}

.profile-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(260px, 0.5fr);
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
}

.profile-logo {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  font-size: 2.2rem;
  overflow: hidden;
}

.profile-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--paper);
  padding: 10px;
}

.profile-main h2 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: -0.055em;
}

.profile-main p:last-child {
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 0;
}

.profile-meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.profile-meta strong { color: var(--ink); }

.empty-state {
  padding: 24px;
  border-radius: 20px;
  background: var(--paper);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.empty-state.small {
  padding: 14px;
}

.preserve-lines {
  white-space: pre-line;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.6;
}

.muted {
  color: rgba(246, 247, 244, 0.82);
  font-weight: 800;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 100vh;
  background: var(--sage);
}

.login-card {
  position: relative;
  overflow: hidden;
  width: min(100%, 520px);
  background: var(--sage);
  color: var(--paper);
  border-radius: 38px;
  padding: 42px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.14);
}

.login-card input {
  background: rgba(255,255,255,0.12);
  color: var(--paper);
  border-color: rgba(255,255,255,0.18);
}

.login-card label { color: rgba(246,247,244,0.78); }

.login-card .eyebrow { color: var(--salmon); }

.login-number {
  position: absolute;
  top: -34px;
  right: 26px;
  font-size: 11rem;
  font-weight: 900;
  color: rgba(218, 148, 130, 0.58);
  line-height: 0.8;
  letter-spacing: -0.08em;
  pointer-events: none;
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-radius: 0 0 30px 30px;
  }
  .nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .main-content { border-radius: 0; }
  .stats-grid,
  .compact-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid.two { grid-template-columns: 1fr; }
  .profile-card { grid-template-columns: auto 1fr; }
  .profile-meta { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .main-content { padding: 22px; }
  .topbar { flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-card { grid-template-columns: 1fr; }
  .hero-number { font-size: 8rem; }
  .stats-grid,
  .compact-stats,
  .form-grid,
  .filters,
  .filters.slim { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .profile-card { grid-template-columns: 1fr; }
  .profile-logo { width: 82px; height: 82px; }
}

.dashboard-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.expenses-filters {
  grid-template-columns: minmax(260px, 1.4fr) minmax(180px, 0.9fr) minmax(180px, 0.9fr) 160px 160px auto;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-content: center;
  min-height: 74px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}

.check-row input {
  width: auto;
  accent-color: var(--salmon);
}

@media (max-width: 1100px) {
  .nav { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .expenses-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-stats,
  .expenses-filters { grid-template-columns: 1fr; }
}


.note-form textarea { min-height: 118px; }

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

.note-item {
  padding: 14px;
  border-radius: 18px;
  background: var(--paper);
}

.note-item time {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.note-item p {
  margin: 0;
  font-weight: 750;
  line-height: 1.5;
  white-space: pre-line;
}

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

.file-card {
  display: grid;
  gap: 6px;
  padding: 15px;
  border-radius: 18px;
  background: var(--paper);
}

.file-card strong {
  letter-spacing: -0.02em;
}

.file-card small {
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 720px) {
  .file-grid { grid-template-columns: 1fr; }
}


.compact-hero { min-height: 210px; }
.compact-hero .hero-number { font-size: clamp(6rem, 12vw, 10rem); }
.compact-hero .hero-text h2 { font-size: clamp(1.8rem, 4vw, 3.6rem); }

.period-filters {
  grid-template-columns: 240px 180px auto;
}

.report-bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 120px;
  gap: 12px;
  align-items: center;
  font-weight: 900;
}

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

.bar-track {
  height: 14px;
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--salmon);
}

.print-body {
  background: var(--paper);
  color: var(--ink);
}

.print-page {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 36px;
}

.print-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.print-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.055em;
}

.print-section {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-top: 18px;
}

.print-section h2 {
  margin: 0 0 14px;
  letter-spacing: -0.035em;
}

@media (max-width: 720px) {
  .period-filters,
  .bar-row { grid-template-columns: 1fr; }
}

@media print {
  .no-print { display: none !important; }
  body, .print-body { background: #fff; }
  .print-page { width: 100%; padding: 0; }
  .stat-card, .print-section { box-shadow: none; break-inside: avoid; }
  table { min-width: 0; }
}

.permission-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
}

.switch-line {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-weight: 900;
  color: var(--ink);
}

.switch-line input {
  width: 18px;
  height: 18px;
}

.permission-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.permission-pills span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.token-box,
.token-section {
  display: grid;
  gap: 8px;
}

.token-box input,
.token-section input {
  width: 100%;
  min-width: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
}

.token-box.compact input {
  min-width: 320px;
}

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

.link-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--salmon-dark);
  font-weight: 900;
  cursor: pointer;
}

.badge.success {
  background: rgba(140, 159, 125, 0.18);
  color: var(--sage-dark);
}

.badge.muted {
  background: var(--paper-2);
  color: var(--muted);
}

.btn.danger {
  color: var(--salmon-dark);
  border-color: rgba(199, 111, 92, 0.35);
}

.danger-form {
  margin-top: 14px;
}

.external-shell .brand-mark {
  background: var(--sage);
}

@media (max-width: 900px) {
  .permission-panel { grid-template-columns: 1fr; }
  .token-box.compact input { min-width: 220px; }
}


.client-mini.is-overdue {
  background: rgba(184, 95, 82, 0.10);
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.text-right { text-align: right; }

.status-open {
  color: var(--danger);
  font-weight: 900;
}


.health-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 54px;
  border-radius: 18px;
  background: var(--paper-2);
  color: var(--sage-dark);
  font-weight: 900;
}

.badge.warning {
  background: rgba(218, 148, 130, 0.18);
  color: var(--salmon-dark);
}

.badge.danger {
  background: rgba(184, 95, 82, 0.16);
  color: var(--danger);
}

.analysis-table table {
  min-width: 1080px;
}

.analysis-panel-note {
  margin: -6px 0 18px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.5;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
}

.nav a i {
  width: 20px;
  text-align: center;
  font-size: 0.98rem;
  color: var(--salmon);
  opacity: 0.92;
}

.nav a span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav a.active i,
.nav a:hover i {
  color: var(--paper);
  opacity: 1;
}

.sidebar-footer i {
  color: var(--salmon);
}

.btn i,
.panel-header a i,
.inline-icon {
  font-size: 0.95em;
}

.panel-header h3 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.panel-icon {
  color: var(--salmon-dark);
  font-size: 0.96em;
}

.stat-card {
  position: relative;
}

.stat-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 13px;
  background: rgba(218, 148, 130, 0.14);
  color: var(--salmon-dark);
  margin-bottom: 14px;
}

.profile-meta span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-meta i {
  width: 16px;
  color: var(--salmon-dark);
}

.file-card strong i {
  color: var(--salmon-dark);
  margin-right: 4px;
}


/* Phase: compact UI density + project date clarity */
html { font-size: 14px; }

.app-shell { grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { padding: 22px 18px; }
.brand { gap: 11px; margin-bottom: 28px; }
.brand-mark { width: 46px; height: 46px; border-radius: 15px; }
.nav { gap: 6px; }
.nav a { padding: 10px 12px; }
.main-content { padding: 26px; border-top-left-radius: 30px; }
.topbar { gap: 18px; margin-bottom: 20px; }
.topbar h1,
.login-card h1 { font-size: clamp(1.7rem, 3vw, 3rem); }
.btn { min-height: 38px; padding: 10px 15px; }
.hero-card { min-height: 210px; padding: clamp(22px, 3vw, 38px); margin-bottom: 18px; }
.hero-number { font-size: clamp(6rem, 14vw, 11rem); }
.hero-text h2 { font-size: clamp(1.7rem, 4vw, 3.5rem); }
.hero-text p:last-child { font-size: 1rem; }
.stats-grid { gap: 12px; margin-bottom: 14px; }
.stat-card { padding: 18px; border-radius: 18px; }
.stat-card strong { font-size: clamp(1.25rem, 2vw, 1.9rem); }
.content-grid.two { gap: 14px; margin-bottom: 14px; }
.panel,
.profile-card { padding: 20px; border-radius: 22px; }
.panel-header { margin-bottom: 14px; }
.panel-header h3 { font-size: 1.12rem; }
.profile-card { gap: 16px; }
.profile-logo { width: 78px; height: 78px; border-radius: 22px; font-size: 1.8rem; }
.profile-main h2 { font-size: clamp(1.65rem, 2.6vw, 2.7rem); }
.client-mini { padding: 10px; border-radius: 15px; }
.avatar { width: 42px; height: 42px; border-radius: 15px; }
.form-grid { gap: 13px; }
input,
select,
textarea { padding: 11px 12px; border-radius: 13px; }
th,
td { padding: 11px 10px; }
.empty-state { padding: 18px; }

.field-hint {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.key-dates-panel { margin-bottom: 14px; }
.key-date-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.key-date-card {
  display: grid;
  gap: 6px;
  padding: 15px;
  border-radius: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.key-date-card span {
  color: var(--muted);
  font-weight: 900;
}
.key-date-card strong {
  font-size: 1.35rem;
  letter-spacing: -0.035em;
}
.key-date-card small {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}
.key-date-card.success {
  background: rgba(82, 109, 96, 0.11);
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .key-date-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .main-content { padding: 18px; }
  .key-date-grid { grid-template-columns: 1fr; }
}

/* Admin 2FA */
.two-factor-card {
  max-width: 520px;
}

.qr-box {
  display: flex;
  justify-content: center;
  padding: 14px;
  border-radius: 22px;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.45);
}

.qr-box img {
  width: 210px;
  height: 210px;
  display: block;
}

.secret-box {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
}

.secret-box span {
  color: rgba(246,247,244,0.62);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.secret-box code {
  color: #fff;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  color: rgba(246,247,244,0.78);
}

.check-row input {
  width: auto !important;
}

.tiny-note {
  font-size: 0.86rem;
}

/* Admin security settings */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 18px;
}

.settings-grid .span-full {
  grid-column: 1 / -1;
}

.security-status-panel .panel-header h3,
.settings-grid .panel-header h3 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

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

.security-summary > div {
  display: grid;
  gap: 5px;
  padding: 14px;
  border-radius: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.security-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 900;
}

.security-summary strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.security-note {
  margin: 16px 0 0;
  line-height: 1.55;
}

.admin-qr-box {
  margin: 14px 0;
  background: var(--paper);
  border: 1px solid var(--line);
}

.admin-secret-box {
  margin: 12px 0;
  background: var(--paper);
  border: 1px solid var(--line);
}

.admin-secret-box span {
  color: var(--muted);
}

.admin-secret-box code {
  color: var(--ink);
}

.security-form {
  margin-top: 14px;
}

.security-secondary-action {
  margin-top: 10px;
}

.form-actions.left {
  justify-content: flex-start;
}

@media (max-width: 980px) {
  .settings-grid { grid-template-columns: 1fr; }
  .security-summary { grid-template-columns: 1fr; }
}

/* Phase: contrast hardening across light/dark surfaces */
.muted {
  color: var(--muted);
  font-weight: 800;
}

.panel .muted,
.profile-card .muted,
.stat-card .muted,
.table-wrap .muted,
.settings-grid .muted,
.security-note,
.field-hint,
.tiny-note {
  color: var(--muted);
}

.panel p,
.profile-card p,
.stat-card p,
.security-status-panel p,
.settings-grid p,
.security-summary strong,
.key-date-card strong,
.file-card strong,
.note-item p {
  color: var(--ink);
}

.login-card .muted,
.login-card .tiny-note,
.login-card p {
  color: rgba(246, 247, 244, 0.82);
}

.login-card h1,
.login-card label,
.login-card .flash span,
.login-card .toast-popup span {
  color: var(--paper);
}

.login-card .flash.success,
.login-card .flash.danger,
.login-card .flash.warning,
.login-card .flash.info {
  color: var(--paper);
}

.login-card input,
.login-card textarea,
.login-card select {
  background: rgba(255,255,255,0.13);
  color: var(--paper);
  border-color: rgba(255,255,255,0.24);
}

.login-card input::placeholder,
.login-card textarea::placeholder {
  color: rgba(246, 247, 244, 0.56);
}

.login-card input:focus,
.login-card textarea:focus,
.login-card select:focus {
  background: rgba(255,255,255,0.18);
  color: var(--paper);
  border-color: rgba(218, 148, 130, 0.72);
}

.check-row {
  color: var(--ink);
  background: var(--paper);
}

.check-row span,
.check-row strong,
.check-row small {
  color: inherit;
}

.login-card .check-row {
  color: rgba(246, 247, 244, 0.82);
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
}

.login-card .check-row input {
  accent-color: var(--salmon);
}

.secret-box {
  background: var(--paper);
  border-color: var(--line);
}

.secret-box span {
  color: var(--muted);
}

.secret-box code {
  color: var(--ink);
}

.login-card .secret-box {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.16);
}

.login-card .secret-box span {
  color: rgba(246,247,244,0.68);
}

.login-card .secret-box code {
  color: var(--paper);
}

.btn.danger {
  background: rgba(184, 95, 82, 0.11);
  color: var(--danger);
}

.btn.danger:hover {
  background: rgba(184, 95, 82, 0.16);
}

/* External collaborator access-scope clarity */
.collaborator-access-panel {
  display: grid;
  gap: 18px;
}

.access-scope-box,
.permissions-box,
.access-preview {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,0.58);
  padding: 16px;
}

.access-scope-box {
  display: grid;
  gap: 14px;
}

.access-scope-box h3,
.permissions-box h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 1.05rem;
}

.access-scope-box p,
.permissions-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.scope-card {
  display: flex !important;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.scope-card:hover {
  transform: translateY(-1px);
  border-color: rgba(82, 109, 96, 0.38);
  box-shadow: 0 14px 30px rgba(23, 33, 28, 0.08);
}

.scope-card input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--sage);
}

.scope-card strong,
.scope-card small {
  display: block;
  color: var(--ink);
}

.scope-card small {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
  margin-top: 4px;
}

.scope-card:has(input:checked) {
  border-color: rgba(82, 109, 96, 0.62);
  background: rgba(82, 109, 96, 0.08);
}

.project-scope-field.is-hidden {
  display: none;
}

.project-scope-field select:disabled {
  opacity: 0.6;
}

.permissions-box .permission-panel {
  margin-top: 10px;
}

.inline-header {
  align-items: flex-start;
  margin-bottom: 0;
}

.access-preview {
  display: grid;
  gap: 5px;
  background: rgba(82, 109, 96, 0.08);
  color: var(--ink);
}

.access-preview strong {
  color: var(--sage-dark);
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.access-preview span {
  color: var(--ink);
  font-weight: 900;
  line-height: 1.45;
}

@media (max-width: 820px) {
  .scope-options {
    grid-template-columns: 1fr;
  }
}


/* Final polish: auto-dismiss toasts + collapsible sidebar */
.toast-popup {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  pointer-events: auto;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast-popup.is-hiding {
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
}

.toast-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.58);
  color: currentColor;
  cursor: pointer;
  opacity: 0.76;
  transition: opacity 160ms ease, background 160ms ease, transform 160ms ease;
}

.toast-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.82);
  transform: scale(1.04);
}

.login-card .toast-close {
  color: var(--paper);
  background: rgba(255,255,255,0.14);
}

.login-card .toast-close:hover {
  background: rgba(255,255,255,0.24);
}

.sidebar,
.app-shell,
.main-content,
.brand,
.nav a,
.nav a span,
.sidebar-footer,
.sidebar-footer span,
.sidebar-footer a {
  transition: grid-template-columns 220ms ease, padding 220ms ease, border-radius 220ms ease, width 220ms ease, opacity 160ms ease, transform 160ms ease, background 160ms ease;
}

.sidebar {
  isolation: isolate;
}

.sidebar-toggle {
  position: absolute;
  top: 78px;
  right: -16px;
  z-index: 5;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 999px;
  background: var(--paper);
  color: var(--sage-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(25, 38, 33, 0.18);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.sidebar-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(25, 38, 33, 0.24);
  background: var(--white);
}

html.sidebar-collapsed .app-shell {
  grid-template-columns: 82px minmax(0, 1fr);
}

html.sidebar-collapsed .sidebar {
  padding: 22px 14px;
  align-items: center;
}

html.sidebar-collapsed .brand {
  width: 100%;
  justify-content: center;
  gap: 0;
  margin-bottom: 30px;
}

html.sidebar-collapsed .brand > span:not(.brand-mark) {
  display: none;
}

html.sidebar-collapsed .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 15px;
}

html.sidebar-collapsed .nav {
  width: 100%;
}

html.sidebar-collapsed .nav a {
  width: 52px;
  min-height: 44px;
  padding: 12px 0;
  margin: 0 auto;
  justify-content: center;
  gap: 0;
}

html.sidebar-collapsed .nav a span {
  display: none;
}

html.sidebar-collapsed .nav a i {
  width: auto;
  font-size: 1rem;
}

html.sidebar-collapsed .sidebar-footer {
  width: 100%;
  flex-direction: column;
  justify-content: center;
  padding-top: 18px;
}

html.sidebar-collapsed .sidebar-footer span {
  display: none;
}

html.sidebar-collapsed .sidebar-footer a {
  width: 48px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255,255,255,0.11);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
}

html.sidebar-collapsed .sidebar-footer a i {
  font-size: 1rem;
}

html.sidebar-collapsed .main-content {
  border-top-left-radius: 26px;
}

@media (max-width: 1100px) {
  .sidebar-toggle {
    display: none;
  }

  html.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  html.sidebar-collapsed .sidebar {
    align-items: stretch;
    padding: 22px 18px;
  }

  html.sidebar-collapsed .brand {
    justify-content: flex-start;
    gap: 11px;
    margin-bottom: 28px;
  }

  html.sidebar-collapsed .brand > span:not(.brand-mark),
  html.sidebar-collapsed .nav a span,
  html.sidebar-collapsed .sidebar-footer span {
    display: initial;
  }

  html.sidebar-collapsed .nav a {
    width: auto;
    min-height: auto;
    padding: 10px 12px;
    margin: 0;
    justify-content: flex-start;
    gap: 11px;
  }

  html.sidebar-collapsed .sidebar-footer {
    flex-direction: row;
    justify-content: space-between;
  }

  html.sidebar-collapsed .sidebar-footer a {
    width: auto;
    height: auto;
    background: transparent;
    font-size: 0.92rem;
  }
}

/* Login/security contrast + lockout countdown hardening */
.flash,
.flash span,
.toast-popup,
.toast-popup span {
  color: inherit;
}

.toast-icon {
  color: currentColor;
}

.login-card .flash,
.login-card .toast-popup {
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 18px 42px rgba(25, 38, 33, 0.22);
}

.login-card .flash.success,
.login-card .toast-popup.success {
  background: rgba(231, 241, 234, 0.96);
  color: var(--sage-dark);
  border-color: rgba(82, 109, 96, 0.28);
}

.login-card .flash.danger,
.login-card .toast-popup.danger {
  background: rgba(255, 228, 222, 0.96);
  color: #8f3e35;
  border-color: rgba(184, 95, 82, 0.38);
}

.login-card .flash.warning,
.login-card .toast-popup.warning {
  background: rgba(255, 237, 224, 0.96);
  color: #9a5648;
  border-color: rgba(218, 148, 130, 0.38);
}

.login-card .flash.info,
.login-card .toast-popup.info {
  background: rgba(246, 241, 234, 0.96);
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.3);
}

.login-card .flash span,
.login-card .toast-popup span,
.login-card .toast-popup .toast-icon {
  color: inherit;
}

.login-card .toast-icon {
  background: rgba(255, 255, 255, 0.58);
}

.auth-lockout-panel {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin: 16px 0 18px;
  border: 1px solid rgba(184, 95, 82, 0.36);
  border-radius: 18px;
  background: rgba(255, 228, 222, 0.96);
  color: #8f3e35;
  box-shadow: 0 16px 36px rgba(25, 38, 33, 0.16);
}

.auth-lockout-icon {
  width: 38px;
  height: 38px;
  border-radius: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(184, 95, 82, 0.14);
  color: #8f3e35;
}

.auth-lockout-panel strong,
.auth-lockout-panel small {
  display: block;
  color: inherit;
}

.auth-lockout-panel strong {
  font-weight: 900;
  line-height: 1.25;
}

.auth-lockout-panel small {
  margin-top: 4px;
  font-weight: 850;
  opacity: 0.88;
}

.auth-lockout-panel b {
  font-size: 1.08em;
  color: #7d342d;
}

.auth-lockout-panel.is-expired {
  background: rgba(231, 241, 234, 0.96);
  color: var(--sage-dark);
  border-color: rgba(82, 109, 96, 0.28);
}

.auth-lockout-panel.is-expired .auth-lockout-icon {
  background: rgba(82, 109, 96, 0.14);
  color: var(--sage-dark);
}

.login-card input:disabled,
.login-card textarea:disabled,
.login-card select:disabled,
.login-card button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.login-card button:disabled:hover {
  transform: none;
}

/* Icon-only row actions and CSS-only delete confirmation modal */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon-action {
  width: 34px;
  height: 34px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(82, 109, 96, 0.08);
  color: var(--sage-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.icon-action:hover {
  transform: translateY(-1px);
  background: rgba(82, 109, 96, 0.14);
  border-color: rgba(82, 109, 96, 0.22);
}

.icon-action-danger {
  background: rgba(184, 95, 82, 0.10);
  color: var(--danger);
}

.icon-action-danger:hover {
  background: rgba(184, 95, 82, 0.16);
  border-color: rgba(184, 95, 82, 0.26);
}

.delete-modal-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.delete-modal {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.delete-modal-toggle:checked + .delete-modal {
  display: flex;
}

.delete-modal-backdrop {
  position: absolute;
  inset: 0;
  display: block;
  background: rgba(25, 38, 33, 0.44);
  backdrop-filter: blur(8px);
  cursor: default;
}

.delete-modal-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 16px;
  border-radius: 30px;
  border: 1px solid rgba(184, 95, 82, 0.18);
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 26px 70px rgba(25, 38, 33, 0.26);
  padding: 22px;
}

.delete-modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: rgba(184, 95, 82, 0.12);
  color: var(--danger);
}

.delete-modal-card h3 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.035em;
}

.delete-modal-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.45;
}

.delete-modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.delete-modal-actions .btn.soft {
  cursor: pointer;
}

@media (max-width: 640px) {
  .delete-modal-card {
    grid-template-columns: 1fr;
  }

  .delete-modal-actions {
    justify-content: stretch;
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .delete-modal-actions .btn,
  .delete-modal-actions .inline-form {
    width: 100%;
  }
}
