:root {
  --font-app: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #111827;
  --ink-soft: #374151;
  --muted: #6b7280;
  --subtle: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --paper: #f3f4f6;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eff6ff;
  --active: #16a34a;
  --borrowed: #3b82f6;
  --due: #f59e0b;
  --overdue: #ef4444;
  --empty: #9ca3af;
  --cabinet: #374151;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 16px 40px rgba(17, 24, 39, 0.12);
  --shadow-lg: 0 34px 90px rgba(17, 24, 39, 0.2);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f9fafb;
    --ink-soft: #d1d5db;
    --muted: #9ca3af;
    --subtle: #6b7280;
    --line: #273244;
    --line-strong: #3b4658;
    --paper: #0f172a;
    --surface: #111827;
    --surface-raised: #172033;
    --primary: #60a5fa;
    --primary-strong: #93c5fd;
    --primary-soft: rgba(96, 165, 250, 0.14);
    --cabinet: #d1d5db;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.34);
    --shadow-lg: 0 34px 90px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-app);
  color: var(--ink);
  background: #eef1f5;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 2px;
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, 430px) minmax(340px, 560px);
  justify-content: center;
  align-items: center;
  gap: 34px;
  padding: 30px;
}

.phone {
  width: min(100%, 393px);
  height: min(852px, calc(100vh - 60px));
  min-height: 720px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  overflow-x: hidden;
  background: var(--paper);
  border: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 32px;
  box-shadow: var(--shadow-lg);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 12px;
  align-items: center;
  padding: 58px 24px 14px;
  background: var(--paper);
  border-bottom: 0;
}

.brand-mark,
.ghost-icon {
  border-radius: 8px;
  font-weight: 850;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: none !important;
  place-items: center;
  border: 1px solid rgba(37, 99, 235, 0.18);
  color: #fff;
  background: linear-gradient(145deg, #111827 0%, #1f2937 52%, #2563eb 100%);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
}

.brand-mark span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.86);
  font-size: 14px;
  line-height: 1;
}

.ghost-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

.screen {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 24px 24px;
}

.auth-card {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.auth-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.auth-brand h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.auth-form {
  gap: 12px;
}

.auth-switch {
  justify-self: center;
}

.form-error {
  padding: 10px 12px;
  border: 1px solid rgba(239, 68, 68, 0.24);
  border-radius: 8px;
  color: #b91c1c;
  background: #fef2f2;
  font-size: 13px;
  font-weight: 800;
}

.empty-state-card {
  display: grid;
  gap: 12px;
}

.screen::-webkit-scrollbar,
.chip-row::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding: 8px 10px 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 800;
}

.bottom-nav button.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-icon {
  width: 24px;
  height: 24px;
  position: relative;
  display: block;
}

.nav-home::before {
  content: "";
  position: absolute;
  inset: 6px 4px 3px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 3px;
}

.nav-home::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 5px;
  width: 14px;
  height: 14px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: rotate(45deg);
}

.nav-keys::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 4px;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.nav-keys::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 13px;
  width: 9px;
  height: 2px;
  background: currentColor;
  box-shadow: 5px 0 0 currentColor, 8px 4px 0 currentColor;
}

.nav-history::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.nav-history::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 8px;
  width: 6px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.nav-profile::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.nav-profile::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 999px 999px 4px 4px;
}

.hero,
.card,
.metric,
.hook-grid,
.modal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.cabinet-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 24px;
  margin-bottom: 16px;
  color: #fff;
  background:
    linear-gradient(145deg, #0f172a, #164e63),
    #111827;
}

.hero::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -42px;
  width: 140px;
  height: 140px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
}

.hero h2 {
  position: relative;
  max-width: 300px;
  margin-bottom: 7px;
  font-size: 29px;
  line-height: 1.08;
  letter-spacing: 0;
}

.hero p {
  position: relative;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 650;
}

.compact-hero {
  padding: 24px;
}

.compact-hero h2 {
  margin-bottom: 8px;
  font-size: 30px;
}

.compact-hero p {
  max-width: 270px;
  margin: 0;
  font-size: 14px;
  line-height: 1.32;
}

.empty-hero {
  min-height: 460px;
  display: grid;
  align-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

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

.home-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 14px;
}

.metric {
  min-width: 0;
  min-height: 64px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 12px 8px;
  overflow: hidden;
  border-left: 0;
  border-top: 4px solid var(--accent, var(--primary));
  text-align: center;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: clamp(17px, 4.8vw, 22px);
  line-height: 1;
  white-space: nowrap;
}

.metric span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.metric-click {
  border-top-width: 1px;
}

.metric-icon {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--accent, var(--primary)) !important;
  background: color-mix(in srgb, var(--accent, var(--primary)) 12%, var(--surface));
  font-size: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

.text-button {
  border: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 800;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.global-search {
  position: relative;
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  z-index: 3;
}

.search-line {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 8px;
}

.search-line.key-only-search {
  display: block;
}

.key-search-line {
  display: block;
  margin: 8px 0 14px;
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  width: 13px;
  height: 13px;
  border: 2px solid #9ca3af;
  border-radius: 50%;
  transform: translateY(-58%);
  pointer-events: none;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: 8px;
  height: 2px;
  border-radius: 99px;
  background: #9ca3af;
  transform: rotate(45deg);
}

.scope-select,
.form-select,
.search-input,
.form-input,
.form-textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.scope-select,
.form-select {
  padding-right: 8px;
}

.search-input::placeholder,
.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--subtle);
}

.search-line .search-input {
  padding-left: 42px;
}

.search-input:focus,
.form-input:focus,
.form-textarea:focus,
.form-select:focus,
.scope-select:focus {
  border-color: color-mix(in srgb, var(--primary) 68%, var(--line));
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-actions,
.recent-searches {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.recent-searches > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.recent-searches em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.mini-chip,
.chip {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 11px;
  font-weight: 800;
}

.mini-chip {
  padding: 4px 9px;
}

.chip {
  flex: 0 0 auto;
  padding: 8px 12px;
}

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

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

.search-dropdown {
  display: none;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.global-search.search-open .search-dropdown,
.global-search.search-has-query .search-dropdown,
.global-search:focus-within .search-dropdown {
  display: grid;
}

.dropdown-clear {
  justify-self: stretch;
  min-height: 32px;
}

.advanced-box {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 12px;
}

.advanced-box span,
.advanced-box strong {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--surface);
}

.search-results {
  display: grid;
  gap: 8px;
}

.search-result {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.search-result span,
.search-result em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.card {
  padding: 14px;
  margin-bottom: 12px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

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

.quick-action {
  min-height: 78px;
  display: grid;
  grid-template-rows: 34px 28px;
  align-items: center;
  justify-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--surface), #f9fafb);
  font-weight: 850;
}

.quick-action span {
  min-height: 28px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  line-height: 1.05;
}

.quick-action strong {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-size: 20px;
}

.primary,
.secondary,
.danger {
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 850;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary {
  color: #fff;
  border: 1px solid var(--primary);
  background: var(--primary);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.16);
}

.primary:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.secondary {
  color: var(--ink-soft);
  border: 1px solid var(--line);
  background: var(--surface);
}

.secondary:hover {
  border-color: var(--line-strong);
  background: #f9fafb;
}

.danger {
  color: #fff;
  border: 1px solid var(--overdue);
  background: var(--overdue);
}

.selector-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 4px 0 8px;
}

.selector-row label,
.form-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.selector-row label {
  position: relative;
  text-transform: uppercase;
}

.selector-row .form-select {
  min-height: 54px;
  padding: 20px 34px 8px 12px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  text-transform: none;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #64748b 50%) calc(100% - 18px) 25px / 6px 6px no-repeat,
    linear-gradient(135deg, #64748b 50%, transparent 50%) calc(100% - 13px) 25px / 6px 6px no-repeat,
    var(--surface);
}

.form-textarea {
  min-height: 78px;
  padding-top: 10px;
  resize: vertical;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 8px;
  scroll-snap-type: x proximity;
}

.fixed-chip-row {
  justify-content: flex-start;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.fixed-chip-row .chip {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 11px;
}

.page-controls,
.zoom-row,
.history-tools {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

.zoom-row {
  margin-top: 12px;
}

.history-tools {
  grid-template-columns: 1fr 1fr;
}

.history-selector-row {
  margin-top: 10px;
}

.history-selector-row label {
  text-transform: none;
}

.compact-select {
  min-height: 42px !important;
  padding: 0 34px 0 12px !important;
}

.history-chip-row {
  padding-bottom: 6px;
}

.scroll-control {
  width: 100%;
  height: 18px;
  margin: 2px 0 10px;
  appearance: none;
  background: transparent;
}

.scroll-control::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: #dbe3ee;
}

.scroll-control::-webkit-slider-thumb {
  width: 74px;
  height: 8px;
  margin-top: 0;
  appearance: none;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.scroll-control::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #dbe3ee;
}

.scroll-control::-moz-range-thumb {
  width: 74px;
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
}

.cabinet-scroll-control {
  margin: 8px 0 0;
}

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

.layout-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin: 10px 0;
}

.hook-grid {
  display: grid;
  gap: calc(10px * var(--zoom, 1)) calc(7px * var(--zoom, 1));
  padding: 8px 2px 10px;
  overflow: auto;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.cabinet-scroll {
  width: 100%;
  overflow: auto;
  padding-bottom: 6px;
}

.cabinet-scroll::-webkit-scrollbar {
  height: 4px;
}

.cabinet-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 48%, #dbe3ee);
}

.cabinet-empty {
  min-height: 178px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  text-align: center;
}

.cabinet-empty strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.12;
}

.cabinet-empty span {
  max-width: 220px;
  font-size: 12px;
  line-height: 1.35;
}

.key-layout {
  transition: transform 160ms ease;
  width: max-content;
  min-width: 100%;
}

.cabinet-card {
  padding: 16px;
  margin-top: 10px;
  margin-bottom: 18px;
}

.cabinet-title-row {
  margin: 0 0 14px;
}

.cabinet-title-row h2 {
  font-size: 18px;
}

.cabinet-page-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.plain-step {
  min-width: 22px;
  min-height: 22px;
  border: 0;
  border-radius: 999px;
  color: var(--ink-soft);
  background: transparent;
  font-weight: 900;
}

.plain-step:hover {
  background: var(--primary-soft);
}

.hook {
  min-width: 0;
  min-height: calc(48px * var(--zoom, 1));
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  padding: 6px 2px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.hook.available {
  border-color: rgba(22, 163, 74, 0.32);
  background: #f0fdf4;
}

.hook.borrowed {
  border-color: rgba(59, 130, 246, 0.34);
  background: #eff6ff;
}

.hook.dueSoon {
  border-color: rgba(245, 158, 11, 0.38);
  background: #fffbeb;
}

.hook.overdue {
  border-color: rgba(239, 68, 68, 0.34);
  background: #fef2f2;
}

.hook.empty {
  color: var(--muted);
  border-style: dashed;
  background: #f9fafb;
}

.hook.highlighted {
  transform: scale(1.08);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
  outline: 3px solid rgba(37, 99, 235, 0.24);
  z-index: 1;
}

.hook strong,
.hook span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hook strong {
  font-size: calc(11px * var(--zoom, 1));
}

.hook span {
  color: var(--muted);
  font-size: calc(8px * var(--zoom, 1));
  font-weight: 800;
}

.status-dot {
  width: calc(12px * var(--zoom, 1));
  height: calc(12px * var(--zoom, 1));
  border-radius: 50%;
  background: var(--empty);
  box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.12);
}

.hook.available .status-dot,
.pill.available,
.pill.return,
.pill.returned {
  background: var(--active);
}

.hook.borrowed .status-dot,
.pill.borrowed {
  background: var(--borrowed);
}

.hook.dueSoon .status-dot,
.pill.dueSoon {
  background: var(--due);
}

.hook.overdue .status-dot,
.pill.overdue {
  background: var(--overdue);
}

.zoom-pill {
  width: 164px;
  min-height: 34px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  gap: 6px;
  margin: 0 auto 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.record,
.manual-row,
.tutorial-row {
  display: grid;
  gap: 5px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.record-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
}

.history-card {
  width: 100%;
  text-align: left;
}

.history-card > span,
.history-card .record-top strong {
  text-align: left;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  color: #fff;
  background: var(--active);
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.pill.cabinet,
.pill.group {
  background: var(--cabinet);
}

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

.small {
  font-size: 12px;
}

.modal-root {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.modal-root[hidden] {
  display: none;
}

.modal-card {
  width: min(100%, 430px);
  max-height: min(820px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.small-modal {
  max-width: 360px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.modal-body {
  overflow: auto;
  padding: 14px;
}

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

.full {
  width: 100%;
}

.detail-grid {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 9px 12px;
  margin-bottom: 14px;
}

.detail-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.timeline,
.export-summary {
  display: grid;
  gap: 6px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.due-card {
  grid-template-columns: minmax(0, 1fr) 86px;
  align-items: center;
}

.record-main {
  display: grid;
  gap: 5px;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.profile-user {
  display: flex;
  gap: 12px;
  align-items: center;
}

.profile-user-button {
  width: 100%;
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
}

.profile-user-button:hover {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: #f8fbff;
}

.avatar {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(145deg, #111827, #2563eb);
  font-weight: 900;
}

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

.profile-row,
.product-row {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 13px 12px 13px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.profile-row span {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.profile-row {
  grid-template-columns: minmax(0, 1fr) auto 30px;
  align-items: center;
  min-height: 46px;
}

.dropdown-button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  justify-self: end;
  border: 1px solid #dbe3ee;
  border-radius: 9px;
  color: #64748b;
  background: #f8fbff;
  font-style: normal;
  font-weight: 850;
}

.product-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  margin-top: 8px;
}

.module-stack {
  display: grid;
  gap: 10px;
}

.roomy-stack {
  gap: 14px;
}

.module-record {
  margin-bottom: 0;
}

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

.management-row > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.compact-danger {
  width: auto;
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
}

.field-card {
  gap: 9px !important;
  padding: 12px;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.08);
}

.field-card-title {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: var(--ink);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 850;
}

.field-card .form-select {
  margin-top: 0;
  border-color: #cbd5e1;
  background-color: #f8fafc;
}

.select-control {
  position: relative;
  display: block;
  width: 100%;
}

.select-control .form-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 54px;
}

.select-button {
  position: absolute;
  right: 7px;
  top: 50%;
  display: grid;
  width: 36px;
  height: 32px;
  place-items: center;
  border-left: 1px solid #cbd5e1;
  pointer-events: none;
  transform: translateY(-50%);
}

.select-button::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #111827;
  border-bottom: 2px solid #111827;
  transform: translateY(-2px) rotate(45deg);
}

.user-profile-detail {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.large-avatar {
  width: 58px;
  height: 58px;
}

.profile-detail-grid {
  grid-template-columns: 112px minmax(0, 1fr);
}

.segmented-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

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

.mini-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mini-actions .secondary,
.mini-actions .danger {
  min-height: 34px;
  font-size: 11px;
}

.switch-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.switch {
  width: 58px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  background: #f3f4f6;
  font-size: 11px;
  font-weight: 850;
}

.switch.on {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.export-box {
  max-height: 220px;
  overflow: auto;
  white-space: pre;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
}

.context-panel {
  display: grid;
  gap: 20px;
  padding: 26px;
  border: 1px solid rgba(17, 24, 39, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

.panel-visual {
  min-height: 270px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(17, 24, 39, 0.98), rgba(37, 99, 235, 0.82)),
    #111827;
}

.mini-cabinet {
  width: 230px;
  height: 156px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  padding: 18px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12px 12px, rgba(255, 255, 255, 0.88) 0 5px, transparent 6px) 0 0 / 24px 24px,
    rgba(255, 255, 255, 0.07);
}

.panel-copy h2 {
  margin-bottom: 10px;
  font-size: 33px;
  line-height: 1.02;
  letter-spacing: 0;
}

.panel-copy p {
  color: var(--muted);
  line-height: 1.55;
}

.panel-link {
  color: var(--primary);
  font-weight: 850;
  text-decoration: none;
}

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

  .context-panel {
    display: none;
  }

  .phone {
    height: calc(100vh - 28px);
    min-height: 680px;
    margin: 0 auto;
  }
}

@media (max-width: 430px) {
  .workspace {
    padding: 0;
  }

  .phone {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

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