:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-strong: #edf2f9;
  --ink: #0f172a;
  --muted: #475569;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --line: #d7e1ee;
  --shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --sidebar: #0f172a;
  --sidebar-ink: #f8fafc;
  --success: #157347;
  --warning: #9a6700;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "SF Pro Display", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 22%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}

body.sidebar-open {
  overflow: hidden;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-screen[hidden],
.app-shell[hidden],
.sidebar-backdrop[hidden] {
  display: none !important;
}

.login-card {
  width: min(480px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(215, 225, 238, 0.88);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 20px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.login-brand h1 {
  font-size: 28px;
}

.login-brand p {
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.5;
}

.login-error {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff1f0;
  border: 1px solid rgba(180, 35, 24, 0.2);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

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

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}

body.sidebar-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 18%),
    var(--sidebar);
  color: var(--sidebar-ink);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  position: relative;
  flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent), var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.brand-mark-sheet {
  position: absolute;
  left: 12px;
  top: 9px;
  width: 20px;
  height: 24px;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.1);
}

.brand-mark-sheet::before,
.brand-mark-sheet::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  height: 2px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.28);
}

.brand-mark-sheet::before {
  top: 7px;
}

.brand-mark-sheet::after {
  top: 12px;
}

.brand-mark-check {
  position: absolute;
  right: 9px;
  bottom: 10px;
  width: 12px;
  height: 7px;
  border-left: 3px solid #0f172a;
  border-bottom: 3px solid #0f172a;
  transform: rotate(-45deg);
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-subtitle {
  color: rgba(244, 247, 251, 0.72);
  font-size: 13px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item,
.dashboard-tab,
.primary-button {
  border: none;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease, opacity 0.18s ease;
}

.nav-item {
  text-align: left;
  border-radius: 14px;
  padding: 13px 14px;
  background: transparent;
  color: var(--sidebar-ink);
  font-weight: 600;
  border: 1px solid transparent;
}

.nav-item:hover,
.dashboard-tab:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 3px 0 0 #8fb1ff;
}

.nav-group-toggle::after {
  content: "▾";
  float: right;
  opacity: 0.75;
  transition: transform 0.18s ease;
}

.nav-group-toggle.active::after {
  transform: rotate(180deg);
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin: -2px 0 6px;
  padding-left: 12px;
}

.nav-submenu.open {
  display: flex;
}

.nav-subitem {
  border: none;
  cursor: pointer;
  text-align: left;
  border-radius: 12px;
  padding: 10px 12px 10px 14px;
  background: transparent;
  color: rgba(244, 247, 251, 0.86);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.18s ease, background-color 0.18s ease, opacity 0.18s ease;
}

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

.nav-subitem.active {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 3px 0 0 #8fb1ff;
}

.content {
  padding: 26px;
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(199, 210, 223, 0.75);
}

.mobile-nav-toggle {
  display: none;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
}

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

#screen-subtitle,
.section-note {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.45;
}

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

input[type="search"] {
  width: 320px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
}

.user-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: #dce7ff;
  color: #23428f;
  font-weight: 700;
}

.screen {
  display: none;
  animation: fadeIn 0.22s ease;
}

.screen.active {
  display: block;
  min-width: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dashboard-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.dashboard-tab,
.primary-button {
  background: var(--panel);
  color: var(--ink);
  padding: 11px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(199, 210, 223, 0.72);
}

.dashboard-tab.active,
.primary-button {
  background: linear-gradient(135deg, var(--accent), #3d78ff);
  color: white;
  border-color: transparent;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.card,
.panel,
.table-shell {
  background: var(--panel);
  border: 1px solid rgba(199, 210, 223, 0.82);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card {
  padding: 18px;
}

.card-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 10px;
}

.dashboard-block-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dashboard-chart-card {
  border: 1px solid rgba(199, 210, 223, 0.72);
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(180deg, #fbfdff, #f2f7ff);
}

.dashboard-chart-title,
.dashboard-table-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: #2a3c56;
  text-transform: none;
}

.dashboard-metric-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dashboard-metric-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.dashboard-metric-label {
  font-size: 13px;
  color: #465b78;
}

.dashboard-metric-track {
  grid-column: 1 / -1;
  height: 10px;
  border-radius: 999px;
  background: #e6edf8;
  overflow: hidden;
}

.dashboard-metric-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2f64ff, #6aa7ff);
}

.dashboard-metric-value {
  font-size: 13px;
  font-weight: 700;
  color: #243a63;
}

.dashboard-empty {
  padding: 14px;
  border: 1px dashed #cad5e6;
  border-radius: 14px;
  color: #69809f;
  background: #fbfdff;
}

.dashboard-table-card {
  border: 1px solid rgba(199, 210, 223, 0.72);
  border-radius: 16px;
  padding: 14px;
  background: #fbfdff;
}

.panel-grid,
.split-layout {
  display: grid;
  gap: 18px;
}

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

.split-layout {
  grid-template-columns: 1fr 1fr;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.compact-grid {
  margin-bottom: 18px;
}

.compact-panel {
  margin-bottom: 18px;
}

.resource-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

#resources-table {
  min-width: 0;
}

.resource-filter-bar,
.org-filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.reference-filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}

.reference-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: #f4f7fb;
  border: 1px solid rgba(199, 210, 223, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.resource-type-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.resource-type-asset {
  background: #dce7ff;
  color: #224592;
}

.resource-type-service_line {
  background: #dff6ea;
  color: #145c3a;
}

.resource-type-sim_card {
  background: #fff0d8;
  color: #8a5400;
}

.resource-title-cell {
  display: grid;
  gap: 4px;
}

.resource-title-sub {
  color: var(--muted);
  font-size: 12px;
}

.resource-table-shell {
  overflow-x: scroll;
  overflow-y: visible;
  width: 100%;
  max-width: 100%;
  display: block;
  padding-bottom: 8px;
  scrollbar-gutter: stable both-edges;
}

.resource-table {
  width: max-content;
  table-layout: fixed;
}

.resource-table-scroll-note {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.resource-table td {
  min-width: 120px;
  max-width: 420px;
  overflow-wrap: anywhere;
}

.resource-header-cell {
  position: relative;
  user-select: none;
  cursor: grab;
  padding-right: 28px;
}

.resource-header-cell.dragging {
  opacity: 0.5;
}

.resource-header-label {
  display: inline-block;
}

.resource-header-hint {
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
}

.resource-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  cursor: col-resize;
}

.resource-resize-handle::after {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  right: 3px;
  width: 2px;
  border-radius: 2px;
  background: rgba(86, 98, 117, 0.35);
}

.resource-table-shell::-webkit-scrollbar {
  height: 12px;
}

.resource-table-shell::-webkit-scrollbar-track {
  background: #dfe6ef;
  border-radius: 999px;
}

.resource-table-shell::-webkit-scrollbar-thumb {
  background: #8ea0b8;
  border-radius: 999px;
}

.resource-row {
  cursor: pointer;
  transition: background-color 0.16s ease;
}

.resource-row:hover {
  background: rgba(31, 94, 255, 0.06);
}

.resource-row.active {
  background: rgba(31, 94, 255, 0.1);
}

.resource-detail-panel {
  position: sticky;
  top: 24px;
}

.resource-detail-card {
  display: grid;
  gap: 16px;
}

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

.resource-detail-head h4 {
  margin-top: 10px;
  font-size: 22px;
}

.resource-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.resource-detail-field {
  padding: 12px;
  border-radius: 14px;
  background: #f4f7fb;
  border: 1px solid rgba(199, 210, 223, 0.72);
}

.resource-detail-empty {
  color: var(--muted);
}

.resource-detail-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.resource-detail-value {
  display: block;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
}

.resource-detail-section {
  display: grid;
  gap: 8px;
}

.resource-detail-notes,
.resource-empty-state {
  padding: 14px;
  border-radius: 14px;
  background: #f4f7fb;
  color: #233247;
  line-height: 1.5;
}

.employee-resource-stack {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.detail-inline-actions {
  margin-top: 16px;
}

.reference-related-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.reference-related-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.reference-related-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.allocation-picker {
  display: grid;
  gap: 10px;
}

.allocation-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(120px, 0.8fr) auto;
  gap: 10px;
}

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

.allocation-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #edf2ff;
  color: #233247;
}

.small-inline-button {
  min-width: 0;
  width: 24px;
  height: 24px;
  padding: 0;
}

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

  .resource-detail-panel {
    position: static;
  }
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.telephony-toolbar {
  margin-bottom: 18px;
}

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

.telephony-form {
  margin-top: 16px;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  font: inherit;
}

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

.secondary-button {
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid rgba(199, 210, 223, 0.78);
  cursor: pointer;
}

.section-header {
  margin-bottom: 14px;
}

.section-header-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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

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

.small-toolbar-button {
  padding: 9px 12px;
  border-radius: 10px;
  box-shadow: none;
}

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

.import-actions {
  margin-top: 18px;
  margin-bottom: 16px;
}

.table-shell {
  overflow-x: auto;
  overflow-y: hidden;
}

.generic-table-shell {
  width: 100%;
}

.generic-table {
  min-width: 100%;
  width: max-content;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  background: var(--panel-strong);
  font-weight: 600;
  color: #223146;
}

.table-shell.telephony-shell {
  overflow-x: auto;
  overflow-y: visible;
  width: 100%;
}

.telephony-table {
  min-width: 1380px;
  width: max-content;
}

.telephony-table td {
  min-width: 120px;
}

.telephony-table .number-cell {
  min-width: 150px;
  font-weight: 600;
}

.tag-trigger {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease;
  color: var(--ink);
}

.tag-trigger:hover {
  transform: translateY(-1px);
  border-color: rgba(31, 94, 255, 0.38);
}

.tag-trigger-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #6b7a90;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}

.tag-trigger-pill {
  display: inline-flex;
  align-items: center;
  margin: 2px 6px 2px 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: #dce7ff;
  color: #244796;
  font-size: 12px;
  white-space: nowrap;
  font-weight: 600;
}

.tag-trigger-empty {
  color: var(--muted);
  font-size: 13px;
}

.cell-input,
.cell-select,
.cell-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.cell-textarea {
  min-height: 42px;
  resize: vertical;
}

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

.small-button {
  padding: 8px 10px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: var(--panel-strong);
  color: var(--ink);
  font-weight: 600;
}

.save-button {
  background: linear-gradient(135deg, var(--accent), #3d78ff);
  color: white;
}

tr:last-child td {
  border-bottom: none;
}

.json-block {
  background: #f4f7fb;
  border-radius: 14px;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.45;
  color: #233247;
}

.flash-message {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 240px;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #1a2740;
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.flash-message.visible {
  opacity: 1;
  transform: translateY(0);
}

.app-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

.app-modal.visible {
  display: flex;
}

.app-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 23, 38, 0.38);
  backdrop-filter: blur(2px);
}

.app-modal-card {
  position: relative;
  width: min(720px, calc(100vw - 32px));
  max-height: min(82vh, 760px);
  overflow: auto;
  padding: 20px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid rgba(199, 210, 223, 0.82);
  box-shadow: 0 30px 90px rgba(13, 23, 38, 0.2);
}

.app-modal-card-sm {
  width: min(560px, calc(100vw - 32px));
}

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

.icon-close {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font: inherit;
}

button:disabled,
.secondary-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.modal-form {
  margin-top: 0;
}

.modal-form-stacked {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(199, 210, 223, 0.78);
  border-radius: 16px;
  background: #f8fbff;
}

.form-section h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #2a3c56;
}

.invoice-recognition [hidden],
#invoice-recognition-items-section[hidden],
#invoice-recognition-confirmation[hidden] {
  display: none;
}

.invoice-recognition .detail-inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.invoice-recognition .secondary-button,
.invoice-draft-item .secondary-button {
  padding: 10px 14px;
  border-radius: 10px;
  min-height: 40px;
  font: inherit;
}

.invoice-recognition .primary-button {
  font: inherit;
}

.invoice-recognition > .section-note:empty {
  display: none;
}

.invoice-recognition-summary dl {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.invoice-detail-notes {
  margin: 14px 0;
  padding: 12px;
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-wrap: anywhere;
}

button.danger-button {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: none;
}

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

#invoice-delete-modal .app-modal-card {
  max-width: 560px;
}

.invoice-detail-notes > div {
  margin-top: 8px;
  white-space: pre-wrap;
}

.invoice-recognition-summary dl > div {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
}

.invoice-recognition-summary dt {
  color: var(--muted);
}

.invoice-recognition-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.invoice-recognition-warnings {
  padding: 12px 12px 12px 30px;
  border-radius: 10px;
  background: #fff5dc;
  color: #725111;
  line-height: 1.5;
}

.invoice-recognition-warnings:empty {
  display: none;
}

.invoice-recognition-text {
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #eef2f7;
  border-radius: 10px;
  font-size: 12px;
}

.invoice-recognition-error {
  color: #b42318;
}

.modal-form-stacked .invoice-needs-review {
  border-color: #c68a20;
  background: #fff9e9;
}

.invoice-draft-item {
  display: grid;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.invoice-details {
  display: block;
}

.invoice-details-summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: #2a3c56;
}

.invoice-details-count {
  margin-left: 8px;
  font-weight: 400;
  color: var(--muted);
}

.invoice-details-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.invoice-details:not([open]) > .invoice-details-content {
  display: none;
}

.invoice-draft-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.invoice-draft-item-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.invoice-recognition-confirmation {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e6c786;
  border-radius: 10px;
  background: #fff9e9;
}

.modal-form-stacked .invoice-recognition-confirmation input {
  width: auto;
  margin-top: 3px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
  color: #3e4f66;
}

.modal-form-stacked input,
.modal-form-stacked select,
.modal-form-stacked textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.modal-form-stacked textarea {
  min-height: 104px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-start;
}

.tag-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.tag-modal.visible {
  display: flex;
}

.tag-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 23, 38, 0.32);
  backdrop-filter: blur(2px);
}

.tag-modal-card {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  max-height: min(70vh, 560px);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(28, 34, 44, 0.18);
  overflow: hidden;
}

.tag-modal-search-wrap {
  padding: 14px 14px 10px;
}

.tag-modal-search {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid #cad4e0;
  border-radius: 18px;
  background: #fff;
  font-size: 16px;
  color: #2f3a4c;
}

.tag-modal-list {
  max-height: min(42vh, 360px);
  overflow: auto;
  padding: 4px 0 0;
}

.tag-modal-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.tag-modal-option:hover {
  background: #eef3fa;
}

.tag-modal-option.active {
  background: #e1ebff;
}

.tag-modal-option-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #7a8799;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  flex: 0 0 auto;
}

.tag-modal-option-label {
  font-size: 15px;
  color: #233247;
}

.tag-modal-option-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #dce7ff;
  color: #244796;
  font-size: 12px;
  font-weight: 600;
}

.tag-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.tag-modal-footer {
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-top: 1px solid #e4e8ee;
  background: #dce7ff;
  color: #244796;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.plain-footer {
  background: #f1f4f8;
  color: #5f6c7f;
}

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

.reference-admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.reference-list {
  max-height: 220px;
}

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

.reference-page-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.reference-access-note {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.reference-access-note.allowed {
  background: #dff7ea;
  color: var(--success);
}

.reference-access-note.readonly {
  background: #fff0d9;
  color: var(--warning);
}

.reference-lock {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.table-action-stack {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reference-table-row {
  cursor: pointer;
  transition: background-color 0.16s ease;
}

.reference-table-row:hover {
  background: rgba(31, 94, 255, 0.05);
}

.reference-table-row.active {
  background: rgba(31, 94, 255, 0.1);
}

.org-filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(180px, 1fr) minmax(180px, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.org-filter-bar input,
.org-filter-bar select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  font: inherit;
}

.employee-department-picker {
  display: grid;
  gap: 10px;
}

.employee-department-picker input[type="search"] {
  width: 100%;
}

.employee-department-options {
  display: grid;
  gap: 10px;
}

.employee-department-options {
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(199, 210, 223, 0.82);
  border-radius: 14px;
  background: #fff;
}

.employee-department-choice {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(199, 210, 223, 0.82);
  background: #f8fbff;
}

.employee-department-choice.active {
  border-color: rgba(31, 94, 255, 0.46);
  background: #edf3ff;
}

.employee-department-choice-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.employee-department-choice-title {
  font-weight: 700;
  color: #223146;
}

.employee-department-choice-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.employee-department-choice-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.employee-department-check,
.employee-department-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #33445b;
  font-weight: 600;
}

.employee-department-check input,
.employee-department-radio input {
  margin: 0;
}

.employee-department-empty {
  padding: 14px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
}

.org-tree,
.employee-roster {
  display: grid;
  gap: 12px;
}

.org-company-block,
.org-department-card,
.employee-roster-card {
  border: 1px solid rgba(199, 210, 223, 0.82);
  border-radius: 16px;
  background: #f8fbff;
}

.org-company-block {
  padding: 16px;
}

.org-company-head,
.employee-roster-head,
.org-department-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.org-company-head {
  margin-bottom: 14px;
}

.org-company-meta,
.org-department-meta,
.employee-roster-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.org-meta-pill,
.employee-meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: #e4edff;
  color: #244796;
  font-size: 12px;
  font-weight: 700;
}

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

.org-department-card {
  padding: 14px;
}

.org-tree-children {
  margin-top: 10px;
  padding-left: 18px;
  border-left: 2px solid #d7e2f1;
  display: grid;
  gap: 10px;
}

.org-empty-state {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
}

.employee-roster-card {
  padding: 16px;
}

.employee-roster-card p {
  color: var(--muted);
  line-height: 1.45;
}

.employee-roster-body {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.employee-roster-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.reference-list.reference-list-lg {
  max-height: 360px;
}

.tag-modal-option-stack {
  min-width: 0;
  display: grid;
  gap: 4px;
  flex: 1 1 auto;
}

.tag-modal-option-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.import-panel {
  max-width: 900px;
}

.import-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.import-template-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--panel-strong);
  box-shadow: var(--shadow-soft);
}

.import-template-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.import-template-card p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
}

.import-template-columns {
  margin: 0 0 14px;
  padding-left: 18px;
  color: var(--text);
  font-size: 14px;
}

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

.import-template-file {
  display: none;
}

.import-panel-legacy {
  margin-top: 20px;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.sort-indicator {
  color: var(--muted);
  font-size: 11px;
}

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

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(86vw, 300px);
    height: auto;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    padding: 18px 14px;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  input[type="search"] {
    width: 100%;
  }

  .content {
    padding: 18px;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .telephony-table {
    min-width: 1180px;
  }

  .tag-modal-card {
    width: min(520px, calc(100vw - 20px));
  }

  .reference-admin-grid {
    grid-template-columns: 1fr;
  }

  .org-filter-bar {
    grid-template-columns: 1fr;
  }

  .reference-filter-bar {
    grid-template-columns: 1fr;
  }
}

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

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand-subtitle {
    display: none;
  }

  .dashboard-tabs {
    flex-wrap: wrap;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .topbar-actions > * {
    width: 100%;
  }

  .reference-screen-head {
    flex-direction: column;
  }

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

  .section-actions {
    width: 100%;
  }

  .login-screen {
    padding: 16px;
  }

  .login-card {
    padding: 20px;
    border-radius: 20px;
  }

  .login-brand {
    align-items: flex-start;
  }

  .login-brand h1 {
    font-size: 24px;
  }

  .user-pill,
  #logout-button {
    justify-content: center;
    text-align: center;
  }

  .allocation-picker-row,
  .reference-related-row {
    grid-template-columns: 1fr;
    display: grid;
  }
}
