:root {
  color-scheme: light;
  --wine-950: #35101d;
  --wine-900: #4a1425;
  --wine-800: #5b1b2e;
  --wine-700: #70253a;
  --wine-100: #f2e7e9;
  --ivory: #f5f1e9;
  --paper: #fffdf9;
  --white: #ffffff;
  --ink: #241a1d;
  --muted: #756b6e;
  --soft: #756b6e;
  --line: #e6dedb;
  --line-strong: #d7cbc8;
  --amber: #a87431;
  --amber-soft: #f4ead8;
  --green: #356c58;
  --green-soft: #e4eee9;
  --blue: #4e647c;
  --blue-soft: #e8edf2;
  --shadow: 0 18px 55px rgba(64, 33, 42, 0.08);
  --radius: 14px;
  --sidebar: 248px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--ivory);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(168, 116, 49, 0.42);
  outline-offset: 2px;
}

svg {
  display: block;
  fill: currentColor;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--white);
  color: var(--wine-900);
  border-radius: 8px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.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;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar);
  flex-direction: column;
  padding: 28px 18px 20px;
  color: #f9f2ee;
  background: var(--wine-900);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-lockup,
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup {
  padding: 0 10px 28px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--wine-900);
  background: #f0e5d9;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 21px;
  font-weight: 700;
}

.brand-copy {
  display: grid;
  letter-spacing: 0.13em;
}

.brand-copy strong {
  font-size: 14px;
}

.brand-copy small {
  color: #d9c8c9;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.primary-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 0 13px;
  color: #d9c9cd;
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-size: 15px;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.07);
}

.nav-item.is-active {
  color: var(--wine-950);
  background: #f0e5d9;
  font-weight: 700;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-count {
  min-width: 24px;
  margin-left: auto;
  padding: 2px 6px;
  color: #fff;
  background: var(--wine-700);
  border-radius: 999px;
  font-size: 12px;
  text-align: center;
}

.nav-item.is-active .nav-count {
  color: #fff;
  background: var(--wine-700);
}

.sidebar-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: auto;
  padding: 16px 12px;
  color: #e9dcde;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-note strong {
  display: block;
  font-size: 13px;
}

.sidebar-note p {
  margin: 3px 0 0;
  color: #c8b6ba;
  font-size: 12px;
  line-height: 1.45;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  margin-top: 5px;
  background: #e2b670;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
}

.main-area {
  min-height: 100vh;
  margin-left: var(--sidebar);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  min-height: 76px;
  align-items: center;
  gap: 24px;
  padding: 14px 32px;
  background: rgba(245, 241, 233, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.global-search,
.inline-search {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  background: var(--white);
  border: 1px solid var(--line);
}

.global-search {
  width: min(480px, 44vw);
  height: 46px;
  padding: 0 12px;
  border-radius: 10px;
}

.global-search:focus-within,
.inline-search:focus-within {
  border-color: var(--wine-700);
  box-shadow: 0 0 0 3px rgba(112, 37, 58, 0.1);
}

.global-search svg,
.inline-search svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}

.global-search input,
.inline-search input {
  width: 100%;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.global-search kbd {
  padding: 2px 6px;
  color: var(--soft);
  background: #f7f4ef;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  transition: transform 120ms ease, background 150ms ease, border-color 150ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button svg {
  width: 18px;
  height: 18px;
}

.button-primary {
  color: #fff;
  background: var(--wine-700);
  border-color: var(--wine-700);
}

.button-primary:hover {
  background: var(--wine-900);
  border-color: var(--wine-900);
}

.button-secondary {
  color: var(--wine-900);
  background: var(--white);
  border-color: var(--line-strong);
}

.button-secondary:hover {
  border-color: var(--wine-700);
}

.button-full {
  width: 100%;
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--wine-900);
  background: #eadbd9;
  border: 1px solid #d9c7c5;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
}

.mobile-brand,
.mobile-nav {
  display: none;
}

.view {
  display: none;
  max-width: 1580px;
  margin: 0 auto;
  padding: 36px 34px 64px;
}

.view.is-active {
  display: block;
  animation: view-in 180ms ease-out;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

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

.overview-heading {
  align-items: center;
}

.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: var(--wine-700);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 3.2vw, 46px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.025em;
}

h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
}

h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.heading-note {
  margin: 8px 0 0;
  color: var(--muted);
}

.demo-chip,
.task-summary {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 11px;
  color: var(--wine-800);
  background: var(--wine-100);
  border: 1px solid #e2ced3;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

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

.metric-card {
  position: relative;
  min-height: 146px;
  padding: 20px;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: var(--accent, var(--wine-700));
}

.metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.metric-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--wine-700);
  background: var(--wine-100);
  border-radius: 8px;
}

.metric-icon svg {
  width: 17px;
  height: 17px;
}

.metric-value {
  display: block;
  margin-top: 16px;
  font-size: clamp(27px, 3vw, 38px);
  font-weight: 750;
  line-height: 1;
  letter-spacing: -0.035em;
}

.metric-detail {
  display: block;
  margin-top: 9px;
  color: var(--soft);
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.65fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(54, 26, 34, 0.02);
}

.attention-panel {
  border-top: 4px solid var(--wine-700);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 21px 22px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  font-size: 22px;
}

.text-button {
  min-height: 40px;
  padding: 0 2px;
  color: var(--wine-700);
  background: transparent;
  border: 0;
  font-size: 14px;
  font-weight: 750;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
}

.text-button:hover {
  text-decoration-color: currentColor;
}

.mini-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.priority-list {
  padding: 4px 22px 10px;
}

.priority-item {
  display: grid;
  grid-template-columns: 6px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.priority-item:last-child {
  border-bottom: 0;
}

.priority-line {
  width: 5px;
  height: 36px;
  background: var(--amber);
  border-radius: 3px;
}

.priority-line.normal {
  background: var(--blue);
}

.priority-copy strong {
  display: block;
  font-size: 15px;
}

.priority-copy span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.due-label {
  color: var(--wine-700);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.stage-bars {
  display: grid;
  gap: 17px;
  padding: 23px 22px 26px;
}

.stage-bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.stage-bar-head strong {
  color: var(--ink);
}

.bar-track {
  height: 7px;
  overflow: hidden;
  background: #eee7e3;
  border-radius: 99px;
}

.bar-fill {
  height: 100%;
  background: var(--wine-700);
  border-radius: inherit;
}

.pipeline-preview {
  overflow: hidden;
}

.compact-leads {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-lead {
  min-width: 0;
  padding: 20px 22px;
  border-right: 1px solid var(--line);
}

.compact-lead:last-child {
  border-right: 0;
}

.compact-lead-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-lead p {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.compact-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--soft);
  font-size: 12px;
}

.stage-chip,
.priority-chip {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.stage-baru { color: #456078; background: var(--blue-soft); }
.stage-kualifikasi { color: #725121; background: var(--amber-soft); }
.stage-sampel { color: #69455d; background: #efe6ed; }
.stage-negosiasi { color: var(--wine-700); background: var(--wine-100); }
.stage-menang { color: var(--green); background: var(--green-soft); }

.heading-actions,
.pipeline-value {
  flex: 0 0 auto;
}

.filter-field select,
.task-composer select,
.lead-form select,
.lead-form input,
.task-composer input {
  min-height: 44px;
  width: 100%;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.filter-field select {
  min-width: 180px;
}

.leads-panel {
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 19px 22px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar h2 {
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
}

.table-toolbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.inline-search {
  width: min(330px, 42vw);
  min-height: 42px;
  padding: 0 11px;
  border-radius: 8px;
}

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

table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  text-align: left;
}

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #faf7f2;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fdfaf5;
}

.cell-primary strong {
  display: block;
  color: var(--ink);
}

.cell-primary span,
.cell-secondary {
  color: var(--muted);
  font-size: 13px;
}

.owner-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.owner-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--wine-700);
  background: var(--wine-100);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
}

.empty-state {
  padding: 56px 24px;
  text-align: center;
}

.empty-state p {
  margin: 5px 0 0;
  color: var(--muted);
}

.pipeline-value {
  color: var(--wine-900);
  font-family: Georgia, serif;
  font-size: 30px;
}

.kanban-help {
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(248px, 1fr));
  gap: 13px;
  width: 100%;
  overflow-x: auto;
  padding-bottom: 12px;
  scroll-snap-type: x proximity;
}

.kanban-column {
  min-height: 480px;
  padding: 13px;
  background: #eee8e0;
  border: 1px solid var(--line);
  border-radius: 12px;
  scroll-snap-align: start;
}

.kanban-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 3px 13px;
}

.kanban-column-head strong {
  font-size: 14px;
}

.kanban-column-head span {
  display: grid;
  min-width: 25px;
  height: 25px;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
  border-radius: 50%;
  font-size: 12px;
}

.kanban-card {
  margin-bottom: 10px;
  padding: 15px;
  background: var(--paper);
  border: 1px solid #ddd3d0;
  border-left: 3px solid var(--wine-700);
  border-radius: 9px;
}

.kanban-card h3 {
  margin-top: 4px;
}

.kanban-card .product-label {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.kanban-card .card-value {
  font-size: 15px;
  font-weight: 800;
}

.kanban-card .card-owner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 12px 0;
  padding-top: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.kanban-card select {
  width: 100%;
  min-height: 40px;
  padding: 0 9px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 13px;
}

.kanban-empty {
  padding: 24px 10px;
  color: var(--soft);
  font-size: 13px;
  text-align: center;
}

.followup-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.55fr);
  gap: 18px;
  align-items: start;
}

.show-completed {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.show-completed input,
.task-check {
  width: 18px;
  height: 18px;
  accent-color: var(--wine-700);
}

.task-list {
  padding: 2px 22px 10px;
}

.task-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.task-item:last-child {
  border-bottom: 0;
}

.task-item.is-complete strong {
  color: var(--soft);
  text-decoration: line-through;
}

.task-copy strong,
.task-copy span {
  display: block;
}

.task-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.task-date {
  color: var(--wine-700);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.task-composer {
  position: sticky;
  top: 96px;
  padding: 22px;
}

.task-composer h2 {
  margin-bottom: 20px;
}

.task-composer form,
.lead-form {
  display: grid;
  gap: 15px;
}

.task-composer label,
.lead-form label {
  display: grid;
  gap: 7px;
}

.task-composer label span,
.lead-form label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.lead-dialog {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.lead-dialog::backdrop {
  background: rgba(38, 16, 23, 0.62);
}

.dialog-close-row {
  display: flex;
  justify-content: flex-end;
  padding: 14px 14px 0;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 27px;
}

.icon-button:hover {
  color: var(--wine-900);
  background: var(--wine-100);
}

.dialog-heading,
.lead-form {
  padding-inline: 28px;
}

.dialog-heading h2 {
  font-size: 28px;
}

.dialog-heading p:last-child {
  margin: 8px 0 22px;
  color: var(--muted);
  font-size: 14px;
}

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

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 7px;
  padding: 18px 0 24px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: min(360px, calc(100% - 44px));
  padding: 13px 16px;
  color: #fff;
  background: var(--wine-950);
  border-radius: 9px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1160px) {
  :root { --sidebar: 218px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .compact-leads { grid-template-columns: 1fr; }
  .compact-lead { border-right: 0; border-bottom: 1px solid var(--line); }
  .compact-lead:last-child { border-bottom: 0; }
  .desktop-only { display: none; }
}

@media (max-width: 820px) {
  :root { --sidebar: 0px; }
  body { padding-bottom: 76px; }
  .sidebar { display: none; }
  .main-area { margin-left: 0; }
  .topbar {
    min-height: 68px;
    padding: 10px 16px;
  }
  .mobile-brand {
    display: flex;
    flex: 0 0 auto;
    color: var(--wine-900);
    font-size: 14px;
    font-weight: 800;
  }
  .mobile-brand .brand-mark { width: 36px; height: 36px; font-size: 19px; }
  .global-search { width: auto; flex: 1; }
  .global-search kbd { display: none; }
  .topbar-actions .button-primary,
  .topbar-actions .avatar { display: none; }
  .view { padding: 28px 18px 42px; }
  .page-heading { align-items: flex-start; }
  .followup-layout { grid-template-columns: 1fr; }
  .task-composer { position: static; }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: 72px;
    padding: 6px 8px max(6px, env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 1px solid var(--line-strong);
    box-shadow: 0 -8px 28px rgba(52, 25, 34, 0.09);
  }
  .mobile-nav-item {
    display: grid;
    min-height: 56px;
    place-items: center;
    align-content: center;
    gap: 3px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: 10px;
  }
  .mobile-nav-item svg { width: 20px; height: 20px; }
  .mobile-nav-item.is-active { color: var(--wine-700); font-weight: 800; }
  .mobile-nav-add {
    width: 52px;
    height: 52px;
    align-self: center;
    justify-self: center;
    color: #fff;
    background: var(--wine-700);
    border: 4px solid var(--paper);
    border-radius: 50%;
    box-shadow: 0 5px 14px rgba(74, 20, 37, 0.25);
    font-size: 25px;
  }
  .toast { bottom: 88px; }
}

@media (max-width: 620px) {
  .topbar { gap: 10px; }
  .mobile-brand span:last-child { display: none; }
  .global-search { min-width: 0; }
  .page-heading { display: grid; gap: 16px; }
  .overview-heading { grid-template-columns: 1fr auto; }
  h1 { font-size: 32px; }
  .heading-note { font-size: 14px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 132px; padding: 15px; }
  .metric-label { align-items: flex-start; font-size: 13px; }
  .metric-icon { width: 30px; height: 30px; }
  .metric-value { font-size: 27px; }
  .metric-detail { line-height: 1.35; }
  .panel-heading { align-items: flex-start; padding: 18px 16px 15px; }
  .priority-list,
  .stage-bars,
  .task-list { padding-inline: 16px; }
  .priority-item { grid-template-columns: 5px minmax(0, 1fr); }
  .priority-item .due-label { grid-column: 2; }
  .table-toolbar { display: grid; padding: 16px; }
  .inline-search { width: 100%; }
  .pipeline-value { font-size: 25px; }
  .kanban { grid-template-columns: repeat(5, minmax(84vw, 1fr)); }
  .kanban-column { min-height: 360px; }
  .task-item { grid-template-columns: auto minmax(0, 1fr); }
  .task-date { grid-column: 2; }
  .show-completed { max-width: 130px; line-height: 1.25; }
  .lead-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); }
  .dialog-heading,
  .lead-form { padding-inline: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .dialog-actions { position: sticky; bottom: 0; margin-inline: -18px; padding: 14px 18px; background: var(--paper); }
}

@media (max-width: 390px) {
  .view { padding-inline: 14px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 122px; }
  .overview-heading { grid-template-columns: 1fr; }
  .demo-chip { justify-self: start; }
}

/* Masumi CRM expanded modules */
.sidebar {
  padding-bottom: 16px;
}

.primary-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.nav-group-label {
  display: block;
  margin: 17px 12px 6px;
  color: #bda9ae;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.nav-group-label:first-child {
  margin-top: 0;
}

.sidebar-note {
  margin-top: 12px;
}

.user-mode select {
  min-height: 42px;
  padding: 0 34px 0 12px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
}

.local-chip {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 12px;
  color: #715222;
  background: var(--amber-soft);
  border: 1px solid #e5d1ad;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.overdue-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -8px 0 20px;
  padding: 14px 16px;
  color: #6f2035;
  background: #f7e7ea;
  border: 1px solid #e8c7ce;
  border-left: 4px solid #9a3449;
  border-radius: 10px;
}

.overdue-banner[hidden] {
  display: none;
}

.overdue-banner div,
.overdue-banner strong,
.overdue-banner span {
  display: block;
}

.overdue-banner span {
  margin-top: 2px;
  color: #714f58;
  font-size: 13px;
}

.pipeline-heading-actions {
  display: flex;
  align-items: end;
  gap: 14px;
}

.pipeline-mobile-filter {
  display: none;
}

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

.metric-card.is-empty-metric .metric-value {
  color: var(--soft);
}

.metric-card .metric-detail strong {
  color: var(--ink);
}

.priority-row {
  display: grid;
  grid-template-columns: 6px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: 0 22px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.priority-row:last-child {
  border-bottom: 0;
}

.priority-marker {
  width: 5px;
  height: 40px;
  background: var(--blue);
  border-radius: 99px;
}

.priority-marker.hot {
  background: #9a3449;
}

.priority-marker.warm {
  background: var(--amber);
}

.priority-copy strong,
.priority-copy span {
  display: block;
}

.priority-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.priority-due {
  color: var(--wine-700);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.target-summary {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.target-summary-row {
  display: grid;
  gap: 7px;
}

.target-summary-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.target-summary-head strong {
  color: var(--ink);
}

.progress-track {
  height: 9px;
  overflow: hidden;
  background: #eee6e3;
  border-radius: 99px;
}

.progress-fill {
  height: 100%;
  background: var(--wine-700);
  border-radius: inherit;
}

.dashboard-pipeline {
  overflow: hidden;
}

.stage-bars.wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 26px;
}

.filter-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}

.filter-toolbar .inline-search {
  width: min(390px, 42vw);
}

.result-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.data-panel,
.realization-panel {
  overflow: hidden;
}

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

.cell-stack strong,
.cell-stack span {
  display: block;
}

.cell-stack span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.heat-chip,
.status-chip,
.sla-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.heat-hot,
.status-overdue,
.sla-late {
  color: #8b263e;
  background: #f5e3e7;
  border-color: #e8c3cb;
}

.heat-warm,
.status-today,
.sla-warning {
  color: #74501c;
  background: var(--amber-soft);
  border-color: #e6d0aa;
}

.heat-cold,
.status-planned {
  color: #425d77;
  background: var(--blue-soft);
  border-color: #cfdae4;
}

.status-done,
.sla-ok,
.status-approved,
.status-accepted,
.status-won {
  color: var(--green);
  background: var(--green-soft);
  border-color: #c9ded3;
}

.status-muted,
.status-cancelled,
.status-rejected,
.status-lost {
  color: #6f6769;
  background: #ece8e7;
  border-color: #dcd5d3;
}

.stage-chip {
  border: 1px solid rgba(74, 20, 37, 0.09);
}

.stage-new { color: #425d77; background: #e7edf3; }
.stage-contacted { color: #4f6577; background: #e8eef1; }
.stage-qualified { color: #72501f; background: #f4ead8; }
.stage-needs-discovery { color: #665074; background: #eee9f1; }
.stage-proposal-sent { color: #6b3f55; background: #f0e6eb; }
.stage-negotiation { color: var(--wine-700); background: var(--wine-100); }
.stage-won { color: var(--green); background: var(--green-soft); }
.stage-lost { color: #696164; background: #eae6e5; }
.stage-nurture { color: #526c60; background: #e8efeb; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mini-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  color: var(--wine-700);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
}

.mini-button:hover {
  border-color: var(--wine-700);
  background: var(--wine-100);
}

.mini-button.is-danger {
  color: #8b2940;
}

.mini-button.is-danger:hover {
  color: #fff;
  background: #8b2940;
  border-color: #8b2940;
}

.empty-state {
  min-height: 210px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  font-family: Georgia, serif;
  font-size: 23px;
  font-weight: 500;
}

.empty-state p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.empty-state .button {
  margin-top: 12px;
}

.kanban {
  grid-template-columns: repeat(9, minmax(252px, 1fr));
}

.kanban-column {
  min-height: 430px;
}

.kanban-card .blocker-note {
  margin: 10px 0;
  padding: 9px;
  color: #714552;
  background: #f7ecef;
  border-left: 3px solid var(--wine-700);
  font-size: 12px;
  line-height: 1.4;
}

.kanban-card .next-action {
  margin: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.record-card {
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.record-card-photo {
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  color: var(--soft);
  background: #eee8e1;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.record-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.record-card-photo span {
  font-size: 13px;
}

.record-card-body {
  padding: 17px;
}

.record-card-body h3 {
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 500;
}

.record-meta {
  display: grid;
  gap: 5px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.target-card {
  padding: 23px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--wine-700);
  border-radius: var(--radius);
}

.target-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.target-card h2 {
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
}

.target-card .target-value {
  display: block;
  margin: 22px 0 8px;
  font-family: Georgia, serif;
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 500;
}

.target-card .target-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.target-editor {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(380px, 1.3fr);
  align-items: end;
  gap: 28px;
  padding: 23px;
}

.target-editor p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.target-editor form {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr auto;
  align-items: end;
  gap: 12px;
}

.target-editor label,
.confirm-dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.target-editor input,
.target-editor select,
.confirm-dialog input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.target-editor.is-locked {
  opacity: 0.66;
}

.target-editor.is-locked form {
  pointer-events: none;
}

.reports-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.backup-panel {
  padding: 23px;
}

.backup-panel > p:not(.section-kicker) {
  margin: 9px 0 22px;
  color: var(--muted);
}

.backup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.backup-actions .button-danger {
  grid-column: 1 / -1;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.button-danger {
  color: #fff;
  background: #8b2940;
  border-color: #8b2940;
}

.button-danger:hover:not(:disabled) {
  background: #6e1d31;
}

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

.manager-note {
  display: block;
  margin-top: 13px;
  color: var(--muted);
}

.project-list {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.project-card {
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.project-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.project-card-head h3 {
  font-family: Georgia, serif;
  font-size: 21px;
  font-weight: 500;
}

.project-card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.project-progress {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 17px;
}

.project-progress-step {
  height: 7px;
  background: #e7dfdc;
  border-radius: 99px;
}

.project-progress-step.is-complete {
  background: var(--wine-700);
}

.project-notes {
  margin: 14px 0 0;
  padding: 10px 12px;
  color: var(--muted);
  background: #f8f4ef;
  border-left: 3px solid var(--amber);
  font-size: 13px;
}

.record-dialog,
.mobile-menu-dialog,
.photo-dialog,
.confirm-dialog {
  width: min(760px, calc(100% - 30px));
  max-height: calc(100dvh - 30px);
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 15px;
  box-shadow: var(--shadow);
}

.record-dialog::backdrop,
.mobile-menu-dialog::backdrop,
.photo-dialog::backdrop,
.confirm-dialog::backdrop {
  background: rgba(38, 16, 23, 0.62);
}

.dialog-top {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 17px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.dialog-top h2 {
  font-size: 27px;
}

#record-dialog-body {
  padding: 20px 22px 24px;
}

.record-form {
  display: grid;
  gap: 18px;
}

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

.form-grid label,
.form-field {
  display: grid;
  gap: 7px;
}

.form-grid label > span,
.form-field > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.form-grid textarea {
  min-height: 90px;
  resize: vertical;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-hint {
  margin: -1px 0 0;
  color: var(--soft);
  font-size: 12px;
  font-weight: 500;
}

.photo-preview {
  display: none;
  width: 100%;
  max-height: 250px;
  margin-top: 8px;
  object-fit: contain;
  background: #eee8e1;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.photo-preview.has-image {
  display: block;
}

.location-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.location-controls span {
  color: var(--muted);
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 -22px -24px;
  padding: 15px 22px;
  background: #faf7f2;
  border-top: 1px solid var(--line);
}

.mobile-menu-dialog {
  width: min(520px, calc(100% - 24px));
}

.mobile-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 18px;
}

.mobile-menu-grid button {
  min-height: 54px;
  padding: 10px;
  color: var(--wine-900);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-weight: 750;
  text-align: left;
}

.photo-dialog {
  width: min(900px, calc(100% - 30px));
}

.photo-dialog img {
  display: block;
  width: calc(100% - 40px);
  max-height: 70vh;
  margin: 20px auto 0;
  object-fit: contain;
  background: #eee8e1;
  border-radius: 10px;
}

.photo-dialog p {
  margin: 12px 20px 20px;
  color: var(--muted);
  font-size: 13px;
}

.confirm-dialog {
  width: min(520px, calc(100% - 30px));
  padding-bottom: 20px;
}

.confirm-dialog > p,
.confirm-dialog > label {
  margin: 18px 22px;
}

.confirm-dialog .dialog-actions {
  margin: 18px 0 -20px;
}

.manager-pin-dialog form,
.forgot-password-dialog form {
  padding: 18px 22px 20px;
}

.manager-pin-dialog form > p:first-child,
.forgot-password-dialog form > p:first-child {
  margin: 0 0 16px;
  color: var(--muted);
}

.manager-pin-dialog form > label,
.forgot-password-dialog form > label {
  display: grid;
  gap: 7px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.manager-pin-dialog input,
.forgot-password-dialog input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.manager-pin-dialog input {
  font-size: 18px;
  letter-spacing: 0.16em;
}

.forgot-password-dialog .auth-feedback {
  margin: 12px 0 0;
}

.forgot-password-dialog .reset-policy {
  margin: 10px 0 0;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.5;
}

.form-error {
  margin: 12px 0 0;
  color: #8b263e;
  font-size: 13px;
  font-weight: 700;
}

.import-preview-body {
  padding: 18px 22px 0;
}

.import-preview-body > p:first-child {
  margin: 0 0 14px;
  color: var(--muted);
}

.import-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.import-summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #f8f4ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.import-summary dt {
  color: var(--muted);
  font-size: 13px;
}

.import-summary dd {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.import-warning {
  margin: 14px 0 0;
  padding: 10px 12px;
  color: #74501c;
  background: var(--amber-soft);
  border-left: 3px solid var(--amber);
  font-size: 13px;
}

@media (max-width: 1160px) {
  .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage-bars.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reports-grid { grid-template-columns: 1fr; }
  .target-editor { grid-template-columns: 1fr; align-items: start; }
}

@media (max-width: 820px) {
  .metric-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-toolbar { flex-wrap: wrap; }
  .filter-toolbar .inline-search { width: 100%; }
  .result-count { margin-left: 0; }
  .target-editor form { grid-template-columns: 1fr 1fr; }
  .target-editor form .button { grid-column: 1 / -1; }
  .record-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .topbar-actions { gap: 7px; }
  .user-mode select { width: 92px; padding: 0 24px 0 9px; color: var(--ink); font-size: 12px; }
  .desktop-button-label { display: none; }
  .topbar-actions .button-primary { display: none; }
  .pipeline-heading-actions { width: 100%; align-items: end; justify-content: space-between; }
  .pipeline-mobile-filter { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
  .pipeline-mobile-filter select { min-height: 44px; padding: 0 34px 0 11px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; }
  .stage-bars.wide { grid-template-columns: 1fr; }
  .overdue-banner { align-items: flex-start; flex-direction: column; }
  .overdue-banner .button { width: 100%; }
  .priority-row { grid-template-columns: 5px minmax(0, 1fr); margin-inline: 16px; }
  .priority-due { grid-column: 2; text-align: left; }
  .record-grid { grid-template-columns: 1fr; }
  .target-cards { grid-template-columns: 1fr; }
  .target-editor form { grid-template-columns: 1fr; }
  .target-editor form .button { grid-column: auto; }
  .backup-actions { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .record-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
  .dialog-top { padding: 17px 16px 14px; }
  #record-dialog-body { padding: 17px 16px 20px; }
  .dialog-actions { position: sticky; bottom: 0; margin: 0 -16px -20px; padding: 13px 16px; }
  .location-controls { align-items: flex-start; flex-direction: column; }
  .mobile-menu-grid { grid-template-columns: 1fr; }
  .kanban.is-mobile-filtered { grid-template-columns: 1fr; overflow: visible; }
  .kanban.is-mobile-filtered .kanban-column { min-height: 360px; }
  .table-wrap { overflow: visible; }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td { display: block; width: 100%; min-width: 0; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .table-wrap tbody { display: grid; gap: 12px; padding: 12px; }
  .table-wrap tbody tr { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
  .table-wrap tbody td { display: grid; grid-template-columns: minmax(104px, 36%) minmax(0, 1fr); align-items: start; gap: 12px; padding: 11px 13px; border-bottom: 1px solid var(--line); }
  .table-wrap tbody td:last-child { border-bottom: 0; }
  .table-wrap tbody td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 800; }
  .table-wrap .cell-stack span { margin-top: 2px; }
  .table-wrap .row-actions { justify-content: flex-start; }
  .mini-button { min-height: 44px; }
  .import-summary { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .metric-grid.compact { grid-template-columns: 1fr; }
  .local-chip { justify-self: start; }
  .global-search input::placeholder { color: transparent; }
  .user-mode select { width: 82px; }
}

/* Authentication and Supabase connection states */
.auth-shell {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 32px 18px;
  background:
    radial-gradient(circle at 18% 18%, rgba(112, 37, 58, 0.1), transparent 31%),
    radial-gradient(circle at 86% 82%, rgba(168, 116, 49, 0.12), transparent 30%),
    var(--ivory);
}

.auth-card {
  width: min(460px, 100%);
  padding: 34px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--wine-700);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  color: var(--wine-900);
}

.auth-brand .brand-copy small {
  color: var(--muted);
}

.auth-card h1 {
  margin: 4px 0 10px;
  color: var(--wine-950);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 6vw, 38px);
  line-height: 1.12;
}

.auth-intro,
.auth-pending-panel p,
.auth-loading-panel p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.auth-form,
.auth-form label {
  display: grid;
  gap: 8px;
}

.auth-form {
  gap: 14px;
}

.auth-form label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.auth-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
}

.auth-feedback {
  min-height: 21px;
  margin: 14px 0 0;
  color: var(--wine-700);
  font-size: 13px;
  font-weight: 650;
}

.auth-feedback.is-success {
  color: var(--green);
}

.auth-footnote {
  margin: 26px 0 0;
  padding-top: 18px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.55;
}

.auth-loading-panel {
  display: grid;
  justify-items: center;
  padding: 28px 6px 12px;
  text-align: center;
}

.auth-loading-panel strong {
  margin: 14px 0 4px;
}

.auth-loading-panel p {
  margin-bottom: 0;
}

.auth-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--wine-100);
  border-top-color: var(--wine-700);
  border-radius: 50%;
  animation: auth-spin 850ms linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

.sync-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #c9ddd3;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.sync-dot {
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}

.sync-pill.is-connecting,
.sync-pill.is-syncing {
  color: #715222;
  background: var(--amber-soft);
  border-color: #e5d1ad;
}

.sync-pill.is-error {
  color: #8d2d43;
  background: #f7e7ea;
  border-color: #e8c7ce;
}

.sync-pill.is-syncing .sync-dot,
.sync-pill.is-connecting .sync-dot {
  animation: sync-pulse 1.2s ease-in-out infinite;
}

@keyframes sync-pulse {
  50% { opacity: 0.32; }
}

.account-summary {
  display: flex;
  align-items: center;
  gap: 9px;
}

.account-summary > span:last-child {
  display: grid;
  line-height: 1.25;
}

.account-summary strong {
  font-size: 13px;
}

.account-summary small {
  max-width: 170px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign-out-button {
  flex: 0 0 auto;
  min-height: 40px;
  padding-inline: 12px;
}

.sign-out-button svg {
  fill: currentColor;
}

.mobile-menu-grid .mobile-menu-sign-out {
  grid-column: 1 / -1;
  color: var(--wine-700);
  border-color: var(--line-strong);
}

.sidebar-note.is-synced .status-dot {
  background: #79bea0;
}

.sidebar-note.is-error .status-dot {
  background: #e08191;
}

@media (max-width: 1240px) {
  .account-summary small { display: none; }
}

@media (max-width: 980px) {
  .sync-pill { width: 34px; justify-content: center; padding: 0; }
  .sync-pill #sync-status-copy { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
}

@media (max-width: 820px) {
  .account-summary { display: none; }
  .sign-out-button { width: 40px; min-height: 40px; padding: 0; }
  .sign-out-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
}

@media (max-width: 620px) {
  .auth-shell { padding: 14px; }
  .auth-card { padding: 26px 22px; }
  .sync-pill { display: none; }
}

.access-chip {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 10px;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid #ccd7e1;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.access-chip[data-role="admin"] {
  color: var(--wine-700);
  background: var(--wine-100);
  border-color: #dec9cf;
}

.access-chip[data-role="viewer"] {
  color: #715222;
  background: var(--amber-soft);
  border-color: #e5d1ad;
}

.read-only-banner {
  display: flex;
  width: calc(100% - 68px);
  max-width: 1512px;
  align-items: center;
  gap: 12px;
  margin: 20px auto -12px;
  padding: 12px 15px;
  color: #604719;
  background: var(--amber-soft);
  border: 1px solid #dfc99f;
  border-left: 4px solid var(--amber);
  border-radius: 10px;
  font-size: 14px;
}

.read-only-banner strong {
  flex: 0 0 auto;
}

.read-only-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.role-hidden {
  display: none !important;
}

.user-management-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.72fr) minmax(0, 1.28fr);
  align-items: start;
  gap: 18px;
}

.user-create-panel form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.user-create-panel .form-feedback {
  min-height: 20px;
  margin: 0;
  color: #8b263e;
  font-size: 13px;
  font-weight: 700;
}

.user-create-panel .form-feedback.is-success {
  color: var(--green);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.user-directory-panel {
  overflow: hidden;
}

.user-capacity-summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.user-capacity {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.user-capacity-item {
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}

.user-capacity-item:last-child {
  border-right: 0;
}

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

.user-capacity-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.user-capacity-item strong {
  margin-top: 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 500;
}

.user-table-wrap table {
  min-width: 940px;
}

.user-table-wrap .empty-state {
  min-height: 240px;
}

.user-role-chip,
.user-state-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.user-role-chip.role-admin {
  color: var(--wine-700);
  background: var(--wine-100);
  border-color: #dec9cf;
}

.user-role-chip.role-viewer {
  color: #715222;
  background: var(--amber-soft);
  border-color: #e5d1ad;
}

.user-role-chip.role-sales {
  color: #425d77;
  background: var(--blue-soft);
  border-color: #ccd7e1;
}

.user-state-chip.is-ready {
  color: var(--green);
  background: var(--green-soft);
  border-color: #c9ddd3;
}

.user-state-chip.is-pending {
  color: #715222;
  background: var(--amber-soft);
  border-color: #e5d1ad;
}

.user-state-chip.is-inactive {
  color: #6f6769;
  background: #ece8e7;
  border-color: #dcd5d3;
}

.user-identity strong,
.user-identity span {
  display: block;
}

.user-identity span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.user-action-protected {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.user-edit-dialog form {
  padding: 20px 22px 24px;
}

.user-edit-dialog input[readonly] {
  color: var(--muted);
  background: #f2eeea;
  cursor: not-allowed;
}

.user-edit-dialog .form-feedback,
.user-delete-dialog .form-feedback {
  min-height: 20px;
  margin: 0;
  color: #8b263e;
  font-size: 13px;
  font-weight: 700;
}

.user-edit-dialog .form-feedback.is-success,
.user-delete-dialog .form-feedback.is-success {
  color: var(--green);
}

.user-delete-dialog form {
  padding: 18px 22px 20px;
}

.user-delete-dialog form > p:first-child {
  margin: 0 0 15px;
  color: var(--muted);
}

.user-delete-target {
  display: grid;
  gap: 3px;
  margin-bottom: 18px;
  padding: 13px 14px;
  background: #f8f4ef;
  border: 1px solid var(--line);
  border-left: 3px solid #8b2940;
  border-radius: 8px;
}

.user-delete-target span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.user-delete-dialog form > label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.user-delete-dialog input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.user-delete-dialog .form-feedback {
  margin-top: 10px;
}

.user-delete-dialog .dialog-actions {
  margin: 18px -22px -20px;
}

@media (max-width: 1160px) {
  .user-management-layout { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .access-chip { display: none; }
  .user-table-wrap table { min-width: 700px; }
  .user-table-wrap th:nth-child(5),
  .user-table-wrap td:nth-child(5) { display: none; }
}

@media (max-width: 820px) {
  .is-viewer .mobile-nav { grid-template-columns: repeat(4, 1fr); }
  .read-only-banner {
    width: calc(100% - 36px);
    margin-top: 16px;
  }
}

@media (max-width: 620px) {
  .user-create-panel form { padding: 18px 16px 20px; }
  .user-edit-dialog form { padding: 17px 16px 20px; }
  .user-delete-dialog form { padding: 17px 16px 20px; }
  .user-delete-dialog .dialog-actions { margin: 18px -16px -20px; }
  .user-table-wrap { overflow: visible; }
  .user-table-wrap table { min-width: 0; }
  .user-capacity { grid-template-columns: 1fr; }
  .user-capacity-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .user-capacity-item:last-child { border-bottom: 0; }
  .user-capacity-summary { white-space: normal; text-align: right; }
  .form-actions .button { width: 100%; }
  .read-only-banner {
    width: calc(100% - 28px);
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    margin-bottom: -10px;
  }
}
