:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #eff4ff;
  --border: #e3e7ec;
  --border-strong: #cbd3dc;
  --text: #0f1419;
  --muted: #5b6470;
  --muted-2: #7a8595;
  --primary: #2563eb;
  --primary-strong: #174fca;
  --primary-soft: #e8f0ff;
  --success: #0e9f6e;
  --success-soft: #e7f8f1;
  --warning: #f59e0b;
  --warning-soft: #fff4d6;
  --danger: #e02424;
  --danger-soft: #feecec;
  --info: #2f7bdc;
  --info-soft: #eaf3ff;
  --shadow: 0 10px 28px rgba(15, 20, 25, 0.08);
  --shadow-lg: 0 24px 70px rgba(15, 20, 25, 0.2);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --nav-height: 78px;
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.24);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116;
  --surface: #171d25;
  --surface-2: #141a21;
  --surface-3: #17233a;
  --border: #26313d;
  --border-strong: #3b4857;
  --text: #e6e9ed;
  --muted: #9aa4b0;
  --muted-2: #7b8593;
  --primary: #3b82f6;
  --primary-strong: #6da2fa;
  --primary-soft: #17233a;
  --success: #34d399;
  --success-soft: #13352d;
  --warning: #fbbf24;
  --warning-soft: #3a3015;
  --danger: #f87171;
  --danger-soft: #402021;
  --info: #60a5fa;
  --info-soft: #182b43;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.55);
  --focus: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  touch-action: manipulation;
}

button {
  border: 0;
}

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

img,
svg {
  display: block;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.75rem, 3vw, 2.75rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.3rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

h3 {
  margin-bottom: 5px;
  font-size: 1rem;
  line-height: 1.3;
}

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

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.mono,
.metric-value,
.date-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.noscript,
.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  padding: 32px;
  text-align: center;
}

.boot-mark {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Authentication */

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(480px, 1.1fr);
  background: var(--bg);
}

.auth-brand {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(32px, 6vw, 80px);
  background:
    radial-gradient(circle at 15% 18%, rgba(59, 130, 246, 0.2), transparent 34%),
    radial-gradient(circle at 85% 75%, rgba(52, 211, 153, 0.14), transparent 36%),
    #0e1116;
  color: #e6e9ed;
}

.auth-brand::after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: -140px;
  width: 410px;
  height: 410px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 45%;
  transform: rotate(20deg);
}

.auth-logo {
  width: 156px;
  height: auto;
}

.auth-brand-copy {
  position: relative;
  z-index: 1;
  max-width: 520px;
}

.auth-brand-copy h1 {
  max-width: 460px;
  font-size: clamp(2.2rem, 5vw, 4.7rem);
}

.auth-brand-copy p {
  max-width: 500px;
  color: #9aa4b0;
  font-size: 1.05rem;
}

.auth-signal {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #9aa4b0;
  font-size: 0.85rem;
}

.auth-signal::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 5px rgba(52, 211, 153, 0.13);
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: clamp(24px, 6vw, 88px);
}

.auth-card {
  width: min(440px, 100%);
}

.auth-card .mobile-auth-logo {
  display: none;
}

.auth-card h2 {
  margin-bottom: 7px;
  font-size: 1.75rem;
}

.auth-card > p {
  margin-bottom: 28px;
  color: var(--muted);
}

.secure-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 22px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
}

.setup-secret {
  padding: 15px;
  overflow-wrap: anywhere;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.recovery-codes li {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Forms and buttons */

.form-stack {
  display: grid;
  gap: 16px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field label,
.field-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}

.field input,
.field select,
.field textarea,
.search-field {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field:focus {
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.field input::placeholder,
.field textarea::placeholder,
.search-field::placeholder {
  color: var(--muted-2);
}

.form-error {
  margin: 0;
  padding: 11px 12px;
  border-left: 3px solid var(--danger);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 650;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button-row.end {
  justify-content: flex-end;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  line-height: 1.2;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

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

.btn:focus-visible,
.icon-btn:focus-visible,
.nav-item:focus-visible,
.sidebar-link:focus-visible,
.card-link:focus-visible,
.breadcrumb-link:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

:root[data-theme="dark"] .btn-primary {
  color: #07111f;
}

.btn-secondary {
  border-color: var(--border);
  background: var(--surface);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.btn-ghost {
  color: var(--primary);
}

.btn-quiet {
  color: var(--muted);
}

.btn-quiet:hover {
  color: var(--text);
  background: var(--surface-2);
}

.danger-text {
  color: var(--danger);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.entity-status-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.entity-actions {
  position: relative;
  flex: 0 0 auto;
}

.entity-menu-trigger {
  width: 38px;
  height: 38px;
}

.entity-menu-trigger[aria-expanded="true"] {
  border-color: var(--primary);
  background: var(--surface-2);
  color: var(--primary);
}

.entity-menu {
  position: absolute;
  z-index: 70;
  top: calc(100% + 6px);
  right: 0;
  width: max-content;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.entity-menu-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 9px 11px;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.entity-menu-item:hover,
.entity-menu-item:focus-visible {
  outline: none;
  background: var(--surface-2);
}

.entity-menu-item.danger {
  color: var(--danger);
}

.entity-menu-item.danger:hover,
.entity-menu-item.danger:focus-visible {
  background: var(--danger-soft);
}

.icon,
.icon svg {
  width: 20px;
  height: 20px;
}

.icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Application shell */

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 22px 16px 18px;
}

.sidebar-logo {
  min-height: 54px;
  display: flex;
  align-items: center;
  padding: 6px 10px 18px;
  background: transparent;
  cursor: pointer;
}

.brand-logo {
  width: 116px;
  height: auto;
  max-height: 48px;
  object-fit: contain;
}

.logo-for-dark {
  display: none;
}

:root[data-theme="dark"] .logo-for-light {
  display: none;
}

:root[data-theme="dark"] .logo-for-dark {
  display: block;
}

.sidebar-nav {
  display: grid;
  gap: 5px;
  margin-top: 18px;
}

.sidebar-section-label {
  margin: 18px 11px 7px;
  color: var(--muted-2);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 650;
  text-align: left;
}

.sidebar-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar-link.active {
  border-color: color-mix(in srgb, var(--primary) 22%, var(--border));
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-link .nav-count {
  margin-left: auto;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
}

.sidebar-status {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.76rem;
}

.sidebar-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.app-column {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 14px clamp(20px, 3.5vw, 48px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}

.topbar-leading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-logo-button {
  display: none;
}

.breadcrumbs {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
}

.breadcrumb-separator {
  color: var(--muted-2);
}

.breadcrumb-link,
.breadcrumb-current {
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
}

.breadcrumb-link {
  color: var(--muted);
}

.breadcrumb-link:hover {
  color: var(--primary);
}

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

.topbar-add {
  min-height: 44px;
}

.notification-button {
  min-width: 64px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.notification-button.rag-red {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.notification-button.rag-amber {
  border-color: var(--warning);
  background: var(--warning-soft);
  color: color-mix(in srgb, var(--warning) 75%, var(--text));
}

.notification-button.rag-green {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.notification-button.rag-info {
  border-color: var(--info);
  background: var(--info-soft);
  color: var(--info);
}

.user-menu {
  position: relative;
}

.avatar-button {
  min-width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.avatar-button.role-admin {
  background: var(--primary);
}

.avatar-button.role-manager {
  background: #7c3aed;
}

.avatar-button.role-foreman {
  background: var(--success);
  color: #05291f;
}

.avatar-button.role-service {
  background: var(--warning);
  color: #2a1900;
}

.avatar-button.role-worker {
  background: #64748b;
}

.profile-popover {
  position: absolute;
  z-index: 45;
  top: calc(100% + 9px);
  right: 0;
  width: 250px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.profile-name {
  margin: 2px 4px 0;
  font-weight: 800;
}

.profile-role {
  margin: 0 4px 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.profile-popover .btn {
  width: 100%;
  justify-content: flex-start;
}

.page-content {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 3.5vw, 48px);
}

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

.page-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.page-actions {
  margin-left: auto;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.section-head h2,
.section-head h3,
.section-head p {
  margin-bottom: 0;
}

.section-link {
  color: var(--primary);
  font-size: 0.84rem;
  font-weight: 750;
}

/* Shared cards, labels and status */

.panel,
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(15, 20, 25, 0.02);
}

.panel {
  padding: 20px;
}

.badge,
.status-badge,
.nav-count {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.badge {
  background: var(--surface-3);
  color: var(--primary);
}

.badge-danger,
.status-critical,
.status-delayed {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-warning,
.status-urgent,
.status-risk {
  background: var(--warning-soft);
  color: color-mix(in srgb, var(--warning) 78%, var(--text));
}

.badge-success,
.status-done,
.status-on-time {
  background: var(--success-soft);
  color: var(--success);
}

.badge-info,
.status-progress {
  background: var(--info-soft);
  color: var(--info);
}

.status-closed,
.status-low {
  background: color-mix(in srgb, var(--muted) 15%, transparent);
  color: var(--muted);
}

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

.empty-state {
  min-height: 210px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 28px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
}

.empty-state .empty-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-state h2,
.empty-state h3,
.empty-state p {
  margin-bottom: 0;
}

.empty-state p {
  max-width: 460px;
  color: var(--muted);
}

.skeleton {
  overflow: hidden;
  position: relative;
  min-height: 120px;
  border-radius: var(--radius);
  background: var(--surface);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 5%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

/* Dashboard */

.welcome {
  margin-bottom: 24px;
}

.welcome h1 {
  font-size: clamp(1.65rem, 2.8vw, 2.4rem);
}

.welcome p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
}

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

.dashboard-card {
  position: relative;
  min-height: 176px;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.dashboard-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.dashboard-card.quick-action {
  grid-column: 1 / -1;
  min-height: 142px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 18px;
  border: 0;
  border-left: 0;
  background: var(--primary);
  color: #fff;
}

:root[data-theme="dark"] .dashboard-card.quick-action {
  color: #07111f;
}

.dashboard-card.quick-action .dashboard-icon {
  grid-row: 1 / span 2;
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
}

.dashboard-card.quick-action .card-copy {
  align-self: end;
}

.dashboard-card.quick-action .card-copy h2 {
  font-size: 1.28rem;
}

.dashboard-card.quick-action .card-copy p {
  color: color-mix(in srgb, currentColor 78%, transparent);
}

.dashboard-card.quick-action .card-arrow {
  grid-column: 3;
  grid-row: 1 / span 2;
  color: inherit;
}

.dashboard-card.rag-red {
  border-color: color-mix(in srgb, var(--danger) 70%, var(--border));
  border-left-color: var(--danger);
  background: color-mix(in srgb, var(--danger-soft) 46%, var(--surface));
}

.dashboard-card.rag-amber {
  border-color: color-mix(in srgb, var(--warning) 70%, var(--border));
  border-left-color: var(--warning);
  background: color-mix(in srgb, var(--warning-soft) 44%, var(--surface));
}

.dashboard-card.rag-green {
  border-color: color-mix(in srgb, var(--success) 60%, var(--border));
  border-left-color: var(--success);
  background: color-mix(in srgb, var(--success-soft) 38%, var(--surface));
}

.dashboard-card.rag-info {
  border-color: color-mix(in srgb, var(--info) 60%, var(--border));
  border-left-color: var(--info);
  background: color-mix(in srgb, var(--info-soft) 42%, var(--surface));
}

.dashboard-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.dashboard-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--text);
}

.dashboard-icon .icon,
.dashboard-icon .icon svg {
  width: 23px;
  height: 23px;
}

.card-copy {
  min-width: 0;
}

.card-copy h2,
.card-copy h3 {
  margin-bottom: 6px;
}

.card-copy p {
  margin-bottom: 0;
  color: var(--muted);
}

.card-copy .card-meta {
  margin-top: 5px;
  font-size: 0.82rem;
}

.card-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 18px;
  color: var(--muted);
  font-weight: 700;
}

.card-arrow {
  color: var(--muted);
}

/* Projects */

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px;
  gap: 12px;
  margin-bottom: 20px;
}

.search-wrap {
  position: relative;
}

.search-wrap .icon {
  position: absolute;
  top: 50%;
  left: 13px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-wrap .search-field {
  padding-left: 42px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr));
  gap: 16px;
}

.project-card {
  min-height: 252px;
  display: flex;
  flex-direction: column;
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.project-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

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

.project-code {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.project-card h2 {
  margin: 5px 0 0;
  font-size: 1.08rem;
}

.project-place {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress {
  width: 100%;
  height: 7px;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--border);
}

.progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--border);
}

.progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--primary);
}

.progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--primary);
}

.project-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.project-metric {
  min-width: 0;
  padding: 11px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
}

.project-metric span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-metric strong {
  display: block;
  margin-top: 2px;
  font-size: 0.98rem;
}

.project-card .card-open {
  padding-top: 13px;
}

.project-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(250px, 0.8fr);
  gap: 16px;
  margin-bottom: 18px;
}

.project-hero {
  padding: 22px;
}

.project-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.project-hero h1 {
  font-size: clamp(1.5rem, 2.5vw, 2.15rem);
}

.project-hero p {
  color: var(--muted);
}

.project-progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}

.project-progress-row .progress {
  flex: 1;
}

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

.metric-card {
  min-height: 110px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-card .metric-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.metric-card .metric-value {
  display: block;
  margin-top: 7px;
  font-size: 1.5rem;
  font-weight: 850;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 18px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 20, 25, 0.07);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 16px;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.list-row-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
}

.list-row-title {
  margin: 0;
  font-weight: 750;
}

.list-row-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

/* Tasks */

.task-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
}

.task-list {
  display: grid;
  gap: 9px;
}

.task-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 76px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
}

.task-row.priority-critical {
  border-left-color: var(--danger);
}

.task-row.priority-urgent {
  border-left-color: var(--warning);
}

.task-row.priority-standard {
  border-left-color: var(--info);
}

.task-row.priority-low {
  border-left-color: var(--muted);
}

.task-state {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
}

.task-state.done {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
  background: var(--success-soft);
  color: var(--success);
}

.task-title {
  margin: 0;
  font-weight: 780;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.suggestion-panel {
  align-self: start;
  position: sticky;
  top: 98px;
  padding: 18px;
  border-left: 3px solid var(--warning);
  background: color-mix(in srgb, var(--warning-soft) 34%, var(--surface));
}

.suggestion-panel p {
  color: var(--muted);
}

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

.suggestion-card {
  padding: 18px;
  border-left: 3px solid var(--warning);
}

.suggestion-card h2 {
  margin: 12px 0 6px;
  font-size: 1.05rem;
}

.suggestion-card p {
  margin: 0 0 14px;
  color: var(--muted);
}

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

.suggestion-actions {
  gap: 8px;
}

/* Calendar */

.calendar-controls,
.message-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.calendar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 15px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.85rem;
}

.filter-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.filter-chip::before {
  content: "✓";
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--success);
  color: #06271e;
  font-size: 0.68rem;
  font-weight: 900;
}

.filter-chip:not(.active)::before {
  content: "";
  border: 1px solid var(--border-strong);
  background: transparent;
}

.filter-chip.active {
  background: var(--success-soft);
  color: var(--text);
}

.suggestion-strip {
  margin-bottom: 20px;
  padding: 16px 18px;
  border-left: 4px solid var(--warning);
  background: color-mix(in srgb, var(--warning-soft) 55%, var(--surface));
}

.suggestion-strip-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.suggestion-strip p {
  margin-bottom: 12px;
}

.date-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.date-navigation h2 {
  margin-bottom: 0;
}

.date-buttons {
  display: flex;
  gap: 7px;
}

.agenda {
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.calendar-event-shell {
  position: relative;
  min-width: 0;
}

.calendar-event-shell > .entity-actions {
  position: absolute;
  z-index: 4;
  top: 13px;
  right: 13px;
}

.calendar-event-shell .entity-menu-trigger {
  width: 34px;
  height: 34px;
  border-color: color-mix(in srgb, var(--border) 75%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}

.calendar-event-shell .agenda-event {
  padding-right: 52px;
}

.agenda-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  min-height: 72px;
  border-bottom: 1px solid var(--border);
}

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

.agenda-time {
  padding: 15px;
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-weight: 800;
}

.agenda-event {
  display: block;
  width: calc(100% - 18px);
  border: 0;
  margin: 9px;
  padding: 10px 12px;
  border-left: 4px solid var(--info);
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.calendar-event-shell[draggable="true"] { cursor: grab; }
.calendar-event-shell.is-dragging { opacity: 0.42; cursor: grabbing; }
.calendar-drop-active { outline: 2px dashed var(--accent); outline-offset: -4px; }

.calendar-drop-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 5px;
}

.calendar-drop-grid-month { grid-template-columns: repeat(7, minmax(130px, 1fr)); }

.calendar-drop-day {
  min-height: 150px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.calendar-drop-day > header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
}

.calendar-drop-day > header span { color: var(--muted); font-size: 0.78rem; }
.calendar-drop-day > div { min-height: 105px; padding: 3px; }
.calendar-drop-day > div > small { display: block; padding: 13px 9px; }
.calendar-drop-day .agenda-event { width: calc(100% - 8px); margin: 4px; }
.calendar-drop-day .agenda-event span { display: none; }
.calendar-drop-day .calendar-event-shell > .entity-actions { top: 6px; right: 6px; }
.calendar-drop-day .calendar-event-shell .entity-menu-trigger { width: 30px; height: 30px; }
.calendar-drop-day .calendar-event-shell .agenda-event { padding-right: 40px; }

.advanced-fields {
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.advanced-fields summary { cursor: pointer; color: var(--accent); font-weight: 700; }
.advanced-fields[open] summary { margin-bottom: 14px; }

.crew-members,
.skill-list,
.compliance-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0;
}

.person-chip,
.skill-list > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
}

.person-chip-warning { color: var(--danger); background: var(--danger-soft); }
.person-chip button { min-width: 26px; min-height: 26px; border-radius: 50%; color: inherit; cursor: pointer; }
.employee-card { color: var(--text); text-align: left; cursor: pointer; }
.privacy-notice { margin-top: 16px; padding: 12px; border-left: 3px solid var(--warning); background: var(--warning-soft); }
.notification-settings { margin-bottom: 12px; }
.notification-row { align-items: flex-start; }
.notification-row > div { min-width: 0; flex: 1; }

.agenda-event.type-warning {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.agenda-event.type-success {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.agenda-event.type-danger {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.agenda-event.type-neutral {
  border-left-color: var(--muted);
  background: color-mix(in srgb, var(--muted) 11%, var(--surface));
}

.agenda-event p {
  margin-bottom: 1px;
  font-weight: 750;
}

.agenda-event span {
  color: var(--muted);
  font-size: 0.76rem;
}

/* Messages */

.message-tabs {
  margin-bottom: 0;
}

.messages-layout {
  min-height: 590px;
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.conversation-pane {
  border-right: 1px solid var(--border);
  background: var(--surface-2);
}

.conversation-head,
.chat-head {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--border);
}

.conversation-head h2,
.chat-head h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.conversation-list {
  margin: 0;
  padding: 8px;
  list-style: none;
}

.conversation-row {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.conversation-row:hover,
.conversation-row.active {
  background: var(--primary-soft);
}

.conversation-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  font-weight: 900;
}

.conversation-copy {
  min-width: 0;
  display: grid;
}

.conversation-copy strong,
.conversation-copy span,
.conversation-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-copy span,
.conversation-copy small {
  color: var(--muted);
  font-size: 0.74rem;
}

.conversation-copy small {
  margin-top: 2px;
}

.conversation-name {
  overflow: hidden;
  margin: 0;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-preview {
  overflow: hidden;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-pane {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-back {
  display: none;
}

.chat-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  overflow-y: auto;
  background:
    linear-gradient(color-mix(in srgb, var(--surface-2) 78%, transparent), color-mix(in srgb, var(--surface-2) 78%, transparent)),
    repeating-linear-gradient(135deg, transparent 0 20px, color-mix(in srgb, var(--border) 30%, transparent) 20px 21px);
}

.message-bubble,
.chat-message {
  max-width: min(620px, 78%);
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 5px var(--radius) var(--radius) var(--radius);
  background: var(--surface);
}

.message-bubble.own,
.chat-message.mine {
  align-self: flex-end;
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  border-radius: var(--radius) 5px var(--radius) var(--radius);
  background: var(--primary-soft);
}

.message-bubble p,
.chat-message p {
  margin-bottom: 4px;
}

.message-bubble time,
.chat-message time {
  color: var(--muted);
  font-size: 0.68rem;
}

.chat-message strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.74rem;
}

.chat-head > div {
  min-width: 0;
}

.chat-head p {
  overflow: hidden;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.message-compose-options { grid-column: 1 / -1; }
.message-compose-options summary { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); cursor: pointer; font-size: 0.78rem; font-weight: 700; }
.message-compose-options summary svg { width: 16px; height: 16px; }
.message-compose-options > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 9px; }
.message-compose-options label { display: grid; gap: 4px; color: var(--muted); font-size: 0.72rem; }
.message-compose-options select { min-height: 70px; }
.message-mentions { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; color: var(--accent); font-size: 0.72rem; }
.message-attachments { display: grid; gap: 5px; margin: 8px 0; }
.message-attachments button { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left; }
.message-attachments svg { width: 17px; height: 17px; }
.message-attachments small { color: var(--muted); }
.message-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.message-convert { color: var(--accent); cursor: pointer; font-size: 0.7rem; font-weight: 700; }

.chat-compose input {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: 0;
  background: var(--surface);
  padding: 9px 12px;
}

.chat-compose input:focus {
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.prototype-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

/* Operational modules */

.section-spaced {
  margin-top: 30px;
}

.metric-grid,
.operational-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 14px;
}

.compact-metrics {
  margin-bottom: 24px;
}

.metric-card {
  min-height: 114px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-value {
  margin-block: 3px;
  font-size: 1.7rem;
}

.operation-card {
  min-width: 0;
  min-height: 178px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

button.operation-card {
  cursor: pointer;
}

button.operation-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.operation-card-head,
.operation-meta,
.detail-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.operation-card h3 {
  margin: 16px 0 4px;
  font-size: 1.04rem;
}

.operation-card > p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.operation-card .operation-note {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.operation-meta {
  flex-wrap: wrap;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.75rem;
}

.data-list {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.data-row {
  min-height: 68px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

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

.data-row p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.data-row-button {
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.data-row-button:hover {
  background: var(--surface-2);
}

.field-hint,
.receipt-line small,
.return-line small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.procurement-summary {
  align-items: stretch;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.procurement-summary p {
  margin: 9px 0 0;
}

.procurement-progress {
  width: min(320px, 48%);
  display: grid;
  gap: 7px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.progress-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
}

.procurement-actions {
  margin-top: 14px;
}

.detail-section {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.delivery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 12px;
}

.delivery-card {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.delivery-card > p {
  margin: 9px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.compact-lines {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.compact-lines li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.78rem;
}

.inline-alert {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
}

.inline-alert.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.delivery-actions {
  margin-top: 12px;
}

.receipt-lines {
  display: grid;
  gap: 9px;
}

.receipt-line,
.return-line {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(110px, 0.35fr) minmax(110px, 0.35fr);
  align-items: end;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.return-line {
  grid-template-columns: minmax(180px, 1fr) minmax(110px, 0.35fr);
}

.receipt-line label,
.return-line label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.receipt-line input,
.return-line input {
  width: 100%;
  margin-top: 5px;
}

@media (max-width: 640px) {
  .procurement-summary {
    display: grid;
  }

  .procurement-progress {
    width: 100%;
  }

  .receipt-line,
  .return-line {
    grid-template-columns: 1fr 1fr;
  }

  .receipt-line > div,
  .return-line > div {
    grid-column: 1 / -1;
  }
}

.user-data-row {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.inventory-toolbar {
  align-items: end;
}

.inventory-toolbar .field label {
  display: block;
  margin-bottom: 5px;
}

.metric-inline {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-inline: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.metric-inline strong {
  color: var(--text);
  font-size: 1.2rem;
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.inventory-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: auto 0 13px;
}

.inventory-values span {
  display: grid;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
}

.inventory-values small {
  color: var(--muted);
  font-size: 0.66rem;
}

.inventory-values strong {
  font-size: 0.88rem;
}

.inventory-values-five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.inventory-tabs {
  margin: 0;
}

.inventory-tabs .badge {
  margin-left: 5px;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}

.card-attention {
  border-color: var(--warning);
  box-shadow: inset 3px 0 0 var(--warning);
}

.data-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.transfer-row small {
  color: var(--muted);
}

.detail-stack {
  display: grid;
  gap: 12px;
}

@media (max-width: 760px) {
  .inventory-values-five {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .transfer-row .data-row-actions {
    grid-column: 1 / -1;
  }
}

.detail-summary {
  margin-bottom: 15px;
}

/* More */

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

.module-card {
  min-height: 130px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.module-card:hover {
  border-color: var(--primary);
}

.module-card .dashboard-icon {
  width: 39px;
  height: 39px;
  margin-bottom: 15px;
}

.module-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

/* Intelligent intake and voice notes */

.toolbar.intake-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.segmented {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.segmented button {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
  white-space: nowrap;
}

.segmented button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(15, 20, 25, 0.1);
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
}

.notice p {
  margin: 2px 0 0;
  color: var(--muted);
}

.intake-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr));
  gap: 14px;
}

.intake-card {
  min-width: 0;
  min-height: 156px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.intake-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.intake-kind-icon,
.voice-ready-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}

.intake-card-main {
  min-width: 0;
}

.intake-card-head,
.proposal-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.intake-card-main > strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.98rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.intake-card-main > p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.intake-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.76rem;
}

.intake-source-card,
.proposal-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.voice-playback {
  width: 100%;
  margin: 6px 0 7px;
}

.source-transcript {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.source-transcript > span,
.proposal-details span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.source-transcript p {
  margin: 7px 0 0;
  white-space: pre-wrap;
}

.intake-runtime-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.proposal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr));
  gap: 14px;
}

.proposal-card h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.proposal-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 15px 0;
}

.proposal-details > div {
  min-width: 0;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.proposal-details strong {
  display: block;
  overflow-wrap: anywhere;
}

.confidence,
.form-note {
  color: var(--muted);
  font-size: 0.78rem;
}

.manual-correction {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 750;
}

.proposal-edit-form [hidden] {
  display: none !important;
}

.proposal-questions {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.question-form + .question-form {
  margin-top: 12px;
}

.question-form label {
  display: block;
  margin-bottom: 7px;
  font-weight: 750;
}

.inline-submit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.inline-submit input {
  min-width: 0;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
}

.inline-submit input:focus {
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.proposal-actions {
  margin-top: 16px;
}

.context-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
}

.voice-recorder {
  min-height: 310px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.voice-recorder .context-chip {
  align-self: stretch;
  margin-bottom: 24px;
}

.voice-recorder > p {
  max-width: 480px;
  color: var(--muted);
}

.voice-recorder > small {
  max-width: 430px;
  margin-top: 14px;
  color: var(--muted);
}

.voice-orb {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.voice-orb .icon,
.voice-orb .icon svg {
  width: 38px;
  height: 38px;
}

.voice-main-button {
  min-height: 48px;
  margin-top: 8px;
}

.recording-signal {
  width: 76px;
  height: 76px;
  margin-bottom: 16px;
  border: 18px solid var(--danger-soft);
  border-radius: 50%;
  background: var(--danger);
  animation: recording-pulse 1.5s ease-in-out infinite;
}

.voice-timer {
  margin-bottom: 12px;
  font: 800 2.4rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.button-row.center {
  justify-content: center;
}

.compact-empty {
  min-height: 220px;
}

@keyframes recording-pulse {
  50% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--danger) 15%, transparent); }
}

/* Dialogs, bottom sheets and toasts */

.overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 10, 15, 0.62);
  backdrop-filter: blur(7px);
}

.dialog {
  width: min(620px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.dialog.dialog-wide {
  width: min(760px, 100%);
}

.dialog-head {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.dialog-head h2 {
  margin-bottom: 3px;
}

.dialog-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.dialog-body {
  padding: 20px 22px 22px;
}

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

.quick-option {
  min-height: 122px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.quick-option:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.quick-option .dashboard-icon {
  width: 38px;
  height: 38px;
  margin-bottom: 12px;
}

.quick-option strong {
  font-size: 0.94rem;
}

.quick-option span:last-child {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.quick-step {
  margin-bottom: 14px;
}

.quick-step .badge {
  margin-bottom: 8px;
}

.toast-stack {
  position: fixed;
  z-index: 200;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 9px;
  pointer-events: none;
}

.toast {
  width: min(380px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease-out;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast p {
  margin-bottom: 0;
  font-size: 0.85rem;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

.bottom-nav {
  display: none;
}

/* Tablet */

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .sidebar {
    padding-inline: 12px;
  }

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

  .suggestion-panel {
    position: static;
    grid-row: 1;
  }

  .messages-layout {
    grid-template-columns: 310px minmax(0, 1fr);
  }
}

/* Mobile */

@media (max-width: 820px) {
  body {
    font-size: 14px;
  }

  h1 {
    font-size: 1.62rem;
  }

  h2 {
    font-size: 1.08rem;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    min-height: 68px;
    gap: 10px;
    padding: 10px 14px;
  }

  .topbar-leading {
    gap: 10px;
  }

  .mobile-logo-button {
    width: 94px;
    min-width: 94px;
    height: 45px;
    display: grid;
    place-items: center;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
  }

  .mobile-logo-button .brand-logo {
    width: 84px;
    max-height: 40px;
  }

  .breadcrumbs {
    gap: 5px;
    font-size: 0.84rem;
  }

  .breadcrumb-link:not(:last-of-type) {
    max-width: 92px;
  }

  .breadcrumb-current {
    max-width: 135px;
  }

  .topbar-actions {
    gap: 7px;
  }

  .notification-button {
    min-width: 54px;
    height: 42px;
    padding-inline: 9px;
  }

  .avatar-button {
    min-width: 42px;
    height: 42px;
    padding-inline: 9px;
  }

  .profile-popover {
    position: fixed;
    top: 66px;
    right: 12px;
  }

  .page-content {
    padding: 21px 15px calc(var(--nav-height) + env(safe-area-inset-bottom) + 34px);
  }

  .page-head {
    align-items: center;
    margin-bottom: 17px;
  }

  .page-head.mobile-compact .page-title-copy {
    display: none;
  }

  .page-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }

  .welcome {
    margin-bottom: 18px;
  }

  .welcome h1 {
    margin-bottom: 5px;
    font-size: 1.52rem;
  }

  .welcome p {
    font-size: 0.9rem;
  }

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

  .dashboard-card {
    min-height: 142px;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    grid-template-rows: auto 1fr;
    column-gap: 13px;
    padding: 15px;
  }

  .dashboard-card.quick-action {
    grid-column: auto;
    min-height: 120px;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    column-gap: 13px;
  }

  .dashboard-card-top {
    display: contents;
  }

  .dashboard-icon,
  .dashboard-card.quick-action .dashboard-icon {
    width: 48px;
    height: 48px;
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .dashboard-card .badge {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
  }

  .dashboard-card .card-copy {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .dashboard-card .card-copy h2,
  .dashboard-card.quick-action .card-copy h2 {
    margin-bottom: 5px;
    font-size: 1rem;
  }

  .dashboard-card .card-copy p {
    font-size: 0.88rem;
  }

  .dashboard-card .card-copy .card-meta {
    font-size: 0.76rem;
  }

  .dashboard-card .card-open {
    display: none;
  }

  .dashboard-card .card-arrow,
  .dashboard-card.quick-action .card-arrow {
    display: block;
    grid-column: 3;
    grid-row: 2;
    align-self: end;
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) 132px;
    gap: 8px;
  }

  .project-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: 12px;
  }

  .project-card {
    min-height: 224px;
    padding: 15px;
  }

  .project-summary {
    grid-template-columns: 1fr;
  }

  .project-hero {
    padding: 17px;
  }

  .project-hero-top {
    flex-direction: column;
    gap: 10px;
  }

  .project-hero h1 {
    font-size: 1.35rem;
  }

  .task-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 70px;
    padding: 11px 12px;
  }

  .task-actions .btn {
    display: none;
  }

  .suggestion-panel {
    padding: 15px;
  }

  .calendar-controls,
  .message-controls {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .calendar-controls .tabs,
  .message-controls .tabs {
    min-width: 0;
    margin-bottom: 0;
  }

  .calendar-controls > .btn,
  .message-controls > .btn {
    flex: 0 0 auto;
    margin-left: auto;
  }

  .tab {
    min-height: 40px;
    padding: 8px 11px;
  }

  .date-navigation {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .date-navigation h2 {
    min-width: 0;
    overflow: hidden;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .date-buttons {
    flex: 0 0 auto;
  }

  .date-buttons .btn {
    min-width: 42px;
    min-height: 42px;
    padding-inline: 10px;
  }

  .agenda-row {
    grid-template-columns: 72px minmax(0, 1fr);
    min-height: 66px;
  }

  .agenda-time {
    padding: 13px 10px;
  }

  .messages-layout {
    min-height: calc(100vh - 185px);
    display: block;
  }

  .messages-layout.chat-open {
    height: calc(100dvh - var(--nav-height) - env(safe-area-inset-bottom) - 172px);
    min-height: 0;
  }

  .conversation-pane {
    min-height: calc(100vh - 185px);
    border-right: 0;
  }

  .chat-pane {
    min-height: calc(100vh - 185px);
  }

  .messages-layout.chat-open .chat-pane {
    height: 100%;
    min-height: 0;
  }

  .messages-layout.chat-open .conversation-pane {
    display: none;
  }

  .messages-layout:not(.chat-open) .chat-pane {
    display: none;
  }

  .chat-back {
    display: inline-grid;
  }

  .chat-body {
    min-height: 0;
  }

  .message-bubble {
    max-width: 88%;
  }

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

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

  .user-data-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .user-data-row > .button-row {
    grid-column: 2 / -1;
    justify-content: flex-end;
  }

  .overlay {
    z-index: 60;
    place-items: end center;
    padding: 0 8px calc(var(--nav-height) + env(safe-area-inset-bottom) + 10px);
  }

  .dialog,
  .dialog.dialog-wide {
    width: 100%;
    max-height: calc(100dvh - var(--nav-height) - env(safe-area-inset-bottom) - 22px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: sheet-in 0.22s ease-out;
  }

  .dialog-head {
    padding: 17px 17px 12px;
  }

  .dialog-body {
    padding: 16px 17px calc(18px + env(safe-area-inset-bottom));
  }

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

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

  .quick-option {
    min-height: 110px;
    padding: 13px;
  }

  .bottom-nav {
    position: fixed;
    z-index: 70;
    right: 0;
    bottom: 0;
    left: 0;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: end;
    padding: 7px max(7px, env(safe-area-inset-left)) calc(7px + env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-right));
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    box-shadow: 0 -12px 32px rgba(5, 10, 15, 0.1);
    backdrop-filter: blur(16px);
  }

  .nav-item {
    min-width: 0;
    min-height: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 650;
  }

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

  .nav-item.active {
    border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
    background: var(--primary-soft);
    color: var(--primary);
  }

  .nav-add {
    min-height: 68px;
    align-self: start;
    margin-top: -17px;
    border-color: var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 8px 22px rgba(5, 10, 15, 0.14);
  }

  .nav-add.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
  }

  .toast-stack {
    right: 10px;
    bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 12px);
  }

  @keyframes sheet-in {
    from { opacity: 0; }
  }
}

@media (max-width: 560px) {
  .auth-shell {
    display: block;
  }

  .auth-brand {
    display: none;
  }

  .auth-panel {
    min-height: 100vh;
    padding: 28px 20px;
  }

  .auth-card .mobile-auth-logo {
    width: 132px;
    display: block;
    margin-bottom: 38px;
  }

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

  .mobile-logo-button {
    width: 80px;
    min-width: 80px;
    padding-inline: 3px;
  }

  .mobile-logo-button .brand-logo {
    width: 75px;
  }

  .breadcrumbs {
    font-size: 0.78rem;
  }

  .breadcrumb-link:not(:last-of-type) {
    max-width: 72px;
  }

  .breadcrumb-current {
    max-width: 96px;
  }

  .notification-button {
    min-width: 48px;
    padding-inline: 7px;
  }

  .notification-button .icon {
    width: 18px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .project-meta {
    gap: 6px;
  }

  .project-metric {
    padding-inline: 5px;
  }

  .summary-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-controls .btn .button-label,
  .message-controls .btn .button-label {
    display: none;
  }

  .calendar-controls > .btn,
  .message-controls > .btn {
    width: 43px;
    padding-inline: 10px;
  }

  .calendar-filters {
    gap: 6px 12px;
  }

  .date-buttons .today-label {
    display: none;
  }

  .quick-grid {
    gap: 8px;
  }

  .quick-option strong {
    font-size: 0.88rem;
  }

  .quick-option span:last-child {
    font-size: 0.7rem;
  }

  .recovery-codes {
    grid-template-columns: 1fr;
  }
}

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

/* Documents 0.4 */
.document-toolbar {
  grid-template-columns: minmax(220px, 1.5fr) minmax(190px, 1fr) minmax(170px, 0.8fr);
  align-items: end;
}

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

.document-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 24px;
  align-items: center;
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.document-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.document-card:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.document-card-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}

.document-card-icon .icon {
  width: 23px;
  height: 23px;
}

.document-card-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.document-card-copy strong,
.document-card-copy span,
.document-card-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-card-copy span,
.document-card-copy small {
  color: var(--muted);
}

.document-card-copy small {
  font-size: 0.78rem;
}

.document-card-arrow {
  color: var(--muted);
}

.document-detail-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.document-detail-summary > div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.document-description {
  margin: 16px 0 0;
  padding: 14px;
  border-left: 3px solid var(--primary);
  background: var(--surface-2);
  color: var(--muted);
}

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

.document-version-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.document-version-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.document-version-number {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.danger-zone {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 760px) {
  .document-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .document-search {
    grid-column: 1 / -1;
  }

  .document-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .document-card {
    min-height: 102px;
    padding: 14px;
  }

  .document-detail-summary {
    grid-template-columns: 1fr 1fr;
  }

  .document-detail-summary > div:last-child {
    grid-column: 1 / -1;
  }

  .document-version-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .document-version-row .button-row {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 430px) {
  .document-toolbar {
    grid-template-columns: 1fr;
  }

  .document-search {
    grid-column: auto;
  }

  .document-card {
    grid-template-columns: 46px minmax(0, 1fr) 20px;
  }
}

@media (max-width: 760px) {
  .toolbar.intake-toolbar {
    align-items: stretch;
  }

  .intake-toolbar .segmented {
    flex: 1;
  }

  .intake-grid,
  .proposal-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .intake-card {
    min-height: 132px;
    padding: 14px;
  }

  .intake-source-card,
  .proposal-card {
    padding: 15px;
  }

  .proposal-details {
    grid-template-columns: 1fr 1fr;
  }

  .voice-recorder {
    min-height: 270px;
  }

  .voice-main-button,
  .inline-submit .btn,
  .proposal-actions .btn {
    min-height: 46px;
  }
}

@media (max-width: 820px) {
  .topbar-add {
    display: none;
  }
}

@media (max-width: 520px) {
  .toolbar.intake-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .segmented button {
    min-height: 42px;
    padding-inline: 10px;
  }

  .intake-card {
    grid-template-columns: 40px minmax(0, 1fr) 18px;
    gap: 10px;
  }

  .intake-kind-icon {
    width: 40px;
    height: 40px;
  }

  .proposal-details,
  .inline-submit {
    grid-template-columns: 1fr;
  }

  .inline-submit .btn {
    width: 100%;
  }

  .voice-recorder .button-row,
  .proposal-actions {
    width: 100%;
  }

  .voice-recorder .button-row .btn,
  .proposal-actions .btn {
    flex: 1;
  }
}

/* Document OCR review 0.9 */
[hidden] {
  display: none !important;
}

.document-ocr-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary-soft);
}

.document-ocr-callout h3,
.document-ocr-callout p {
  margin: 3px 0 0;
}

.document-ocr-callout p {
  color: var(--muted);
}

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

.ocr-review-summary > div {
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.ocr-review-messages ul {
  margin: 7px 0 0;
  padding-left: 18px;
}

.notice.success-notice {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.notice.danger-notice {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.ocr-review-form,
.ocr-review-form fieldset {
  display: grid;
  gap: 16px;
}

.ocr-review-form fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ocr-review-form fieldset:disabled input,
.ocr-review-form fieldset:disabled select {
  opacity: 0.82;
  cursor: not-allowed;
}

.form-section {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.ocr-destination-section {
  border-left: 4px solid var(--warning);
}

.ocr-lines {
  display: grid;
  gap: 10px;
}

.ocr-line {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.ocr-line-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.ocr-line-fields {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 10px;
}

.ocr-line-fields .ocr-description {
  grid-column: span 2;
}

.ocr-line-fields .field label {
  font-size: 0.7rem;
}

.ocr-line-fields .field input {
  min-height: 42px;
  padding: 8px 10px;
}

.ocr-review-actions {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.check-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
}

.check-line input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

/* Core 1.0 — administracja, bezpieczeństwo i wyszukiwanie */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}

.check-row input,
.filter-check input,
.permission-choice input {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  margin-top: 2px;
  accent-color: var(--primary);
}

.check-row span,
.permission-choice span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.check-row small,
.permission-choice small {
  color: var(--muted);
}

.check-list,
.permission-matrix,
.override-list,
.search-results {
  display: grid;
  gap: 12px;
}

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

.permission-matrix {
  max-height: min(52vh, 620px);
  overflow: auto;
  padding-right: 4px;
}

.permission-group {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.permission-group legend {
  padding: 0 7px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.permission-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 112px;
  align-items: start;
  gap: 9px;
  padding: 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.permission-choice select {
  min-height: 38px;
  padding: 6px 8px;
}

.override-entry {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) 100px 120px minmax(170px, 2fr) 180px auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.global-search-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.global-search-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.global-search-field input {
  min-height: 48px;
  border: 0;
  background: transparent;
  font-size: 1.05rem;
  outline: 0;
}

.search-type-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
}

.search-result-row {
  width: 100%;
  text-align: left;
}

.audit-list {
  max-height: 620px;
  overflow: auto;
}

.audit-toolbar .btn {
  align-self: end;
}

.task-workflow-summary,
.task-workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

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

.compact-list .data-row {
  padding: 9px 0;
}

.compact-panel {
  align-items: end;
  margin-top: 14px;
  padding: 13px;
}

.workflow-history {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.workflow-history summary {
  cursor: pointer;
  font-weight: 750;
}

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

.activity-list {
  max-height: 680px;
  overflow: auto;
}

.contact-hierarchy {
  display: grid;
  gap: 8px;
}

.contact-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-left: calc(var(--hierarchy, 0) * 22px);
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.contact-row p,
.contact-row small {
  margin: 2px 0 0;
  color: var(--muted);
}

@media (max-width: 900px) {
  .ocr-review-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ocr-line-fields {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
  }
}

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

  .contact-row {
    margin-left: calc(min(var(--hierarchy, 0), 3) * 10px);
  }
  .workflow-columns {
    grid-template-columns: 1fr;
  }
  .permission-group {
    grid-template-columns: 1fr;
    padding: 10px;
  }

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

  .permission-choice select {
    grid-column: 2;
  }

  .override-entry {
    grid-template-columns: 1fr 1fr;
  }

  .override-entry > :first-child,
  .override-entry > :nth-child(4),
  .override-entry > :nth-child(5) {
    grid-column: 1 / -1;
  }

  .global-search-field {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .global-search-field .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .search-type-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .filter-check {
    flex: 0 0 auto;
  }

  .document-ocr-callout {
    align-items: stretch;
    flex-direction: column;
  }

  .document-ocr-callout .btn {
    width: 100%;
  }

  .ocr-review-summary > div {
    min-height: 72px;
    padding: 11px;
  }

  .form-section {
    padding: 13px;
  }

  .ocr-line-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ocr-line-fields .ocr-description {
    grid-column: 1 / -1;
  }

  .ocr-review-actions .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ocr-review-actions .btn {
    width: 100%;
    min-height: 46px;
  }
}
