/*
 * In Linea Web Net - Professional UI 2026
 * Tema finale isolato: mantiene la logica applicativa e uniforma ogni superficie.
 */

:root {
  color-scheme: light;
  --bg: #f2f5f7;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --panel-muted: #eef1f4;
  --ink: #10263b;
  --ink-soft: #34495a;
  --muted: #526575;
  --line: #dce3e8;
  --line-strong: #c7d1d8;
  --accent: #f47a22;
  --accent-strong: #d8610e;
  --accent-soft: #fff0e5;
  --cyan: #327b9b;
  --green: #2d7a57;
  --green-soft: #e7f4ed;
  --amber: #b7791f;
  --amber-soft: #fff3d8;
  --coral: #bd594f;
  --coral-soft: #fbe9e7;
  --violet: #725ca8;
  --violet-soft: #efebf8;
  --danger: #b13c43;
  --warning: #a26613;
  --success: #28724e;
  --sidebar: #0d3048;
  --sidebar-soft: #173e57;
  --sidebar-line: #2b5269;
  --shadow-soft: 0 1px 2px rgba(21, 31, 39, 0.05), 0 8px 24px rgba(21, 31, 39, 0.05);
  --shadow: 0 2px 5px rgba(21, 31, 39, 0.06), 0 18px 44px rgba(21, 31, 39, 0.1);
  --focus-ring: 0 0 0 3px rgba(244, 122, 34, 0.18);
}

.license-identity {
  border: 1px solid rgba(255, 255, 255, 0.16);
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
  padding: 10px 11px;
}

.license-identity span,
.license-identity small {
  color: rgba(255, 255, 255, 0.68);
  font-size: 11px;
}

.license-identity strong {
  color: #fff;
  font-size: 12px;
  overflow-wrap: anywhere;
}

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

.license-settings-grid > div {
  border-left: 3px solid #f47a22;
  display: grid;
  gap: 4px;
  padding: 8px 12px;
}

.license-settings-grid span {
  color: var(--muted, #64748b);
  font-size: 12px;
}

.license-settings-grid strong {
  color: var(--text, #17212b);
  overflow-wrap: anywhere;
}

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

/* Mobile layout coherence: neutralize the legacy bottom-navigation rules. */
@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .topbar {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between;
    min-height: 60px;
    padding: 8px 10px;
    gap: 8px;
  }

  .topbar-identity {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    gap: 8px;
  }

  .topbar #viewTitle {
    display: block;
    min-width: 0;
    max-width: min(34vw, 130px);
    padding-left: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    display: flex !important;
    flex: 0 0 auto;
    flex-direction: row !important;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    margin: 0;
    gap: 6px;
  }

  .topbar-logo {
    flex: 0 0 auto;
  }

  .search-box,
  #quickAdd,
  .admin-logout-top {
    flex: 0 0 38px;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    border-radius: 7px;
  }

  .search-box {
    padding: 0 9px;
  }

  .search-box input {
    min-width: 0;
  }

  #quickAdd::before,
  .admin-logout-top::before {
    content: none !important;
    display: none !important;
  }

  .admin-logout-top {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0;
  }

  .admin-logout-top svg,
  #quickAdd svg {
    display: block;
    width: 19px;
    height: 19px;
  }

  .sidebar,
  .sidebar:hover,
  .sidebar:focus-within,
  .sidebar.sidebar-open {
    inset: 0 auto 0 0;
    width: min(300px, 88vw);
    height: 100dvh;
    padding: 14px 11px calc(16px + env(safe-area-inset-bottom));
    border: 0;
    border-right: 1px solid var(--sidebar-line);
    border-radius: 0;
    overflow: hidden;
  }

  .sidebar::before,
  .sidebar::after {
    display: block;
  }

  .sidebar .brand,
  .sidebar .sidebar-footer {
    display: flex;
  }

  .sidebar .sidebar-footer {
    width: 100%;
  }

  .nav-list {
    display: flex !important;
    flex: 1 1 auto;
    flex-direction: column !important;
    align-items: stretch;
    grid-template-columns: none !important;
    width: 100%;
    min-width: 0;
    height: auto;
    padding: 0 3px 0 0;
    gap: 3px;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-type: none;
  }

  .nav-group {
    display: block !important;
    flex: 0 0 auto;
    width: 100% !important;
  }

  .nav-group-toggle {
    display: grid !important;
  }

  .nav-item,
  .sidebar:hover .nav-item,
  .sidebar:focus-within .nav-item,
  .sidebar.sidebar-open .nav-item {
    position: relative;
    display: grid !important;
    grid-template-columns: 32px minmax(0, 1fr) 18px !important;
    align-items: center;
    justify-content: initial;
    width: 100% !important;
    min-height: 43px;
    padding: 8px 10px !important;
    border-radius: 7px;
    font-size: 13px;
    line-height: 1.2;
    text-align: left;
    white-space: nowrap;
    scroll-snap-align: none;
  }

  .nav-item::before,
  .nav-submenu button::before {
    content: none !important;
    display: none !important;
  }

  .sidebar .nav-item > span {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar .nav-item > svg:first-child {
    width: 19px;
    height: 19px;
  }

  .nav-submenu,
  .sidebar .nav-submenu {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: auto !important;
    margin: 3px 0 5px 42px !important;
    padding: 0 !important;
    gap: 2px;
  }

  .nav-submenu button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100% !important;
    min-height: 36px;
    padding: 7px 9px !important;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.2;
    text-align: left;
    white-space: nowrap;
  }

  .nav-submenu button svg {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
  }

  .workspace {
    width: 100%;
    max-width: 100%;
    padding: 14px 10px calc(30px + env(safe-area-inset-bottom));
  }
}

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

  .topbar #viewTitle {
    max-width: 30vw;
  }
}

.asset-credentials-field {
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, var(--accent) 6%);
}

.asset-credentials-heading,
.machine-access-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.asset-credentials-heading > div {
  display: grid;
  gap: 3px;
}

.asset-credentials-list,
.machine-access-list {
  display: grid;
  gap: 8px;
}

.asset-credential-row {
  display: grid;
  grid-template-columns: 28px minmax(130px, 0.8fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(170px, 1.2fr) 36px;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.asset-credential-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.asset-credential-row label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.asset-credential-row input {
  width: 100%;
  min-width: 0;
}

.asset-credential-number,
.machine-access-heading > span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.asset-credential-remove {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--line));
  border-radius: 6px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--panel));
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.asset-credential-remove:hover {
  color: #fff;
  background: var(--danger);
}

.machine-access-panel {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.machine-access-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(140px, 1fr) minmax(140px, 1fr) minmax(120px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--panel) 96%, var(--accent) 4%);
}

.machine-access-row span {
  display: grid;
  gap: 2px;
  overflow-wrap: anywhere;
}

.machine-access-row small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.machine-access-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

@media (max-width: 980px) {
  .asset-credential-row {
    grid-template-columns: 28px repeat(2, minmax(0, 1fr)) 36px;
  }

  .asset-credential-notes {
    grid-column: 2 / 4;
  }

  .asset-credential-remove {
    grid-column: 4;
    grid-row: 1;
  }

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

@media (max-width: 620px) {
  .asset-credentials-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .asset-credential-row {
    grid-template-columns: 28px minmax(0, 1fr) 36px;
  }

  .asset-credential-row label,
  .asset-credential-notes {
    grid-column: 2 / 4;
  }

  .asset-credential-remove {
    grid-column: 3;
    grid-row: 1;
  }

  .machine-access-row {
    grid-template-columns: 1fr;
  }
}

@keyframes ui-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes status-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(45, 122, 87, 0);
  }
  45% {
    box-shadow: 0 0 0 5px rgba(45, 122, 87, 0.1);
  }
}

@keyframes auth-grid-flow {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 0 64px;
  }
}

@keyframes auth-structure-drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(-18px, 10px, 0);
  }
}

@keyframes auth-data-travel {
  0% {
    opacity: 0;
    transform: translateX(-35%) scaleX(0.2);
  }
  20% {
    opacity: 0.55;
  }
  70% {
    opacity: 0.32;
  }
  100% {
    opacity: 0;
    transform: translateX(135%) scaleX(0.75);
  }
}

@keyframes auth-sweep-travel {
  0%,
  18% {
    opacity: 0;
    transform: translateX(-28vw);
  }
  35% {
    opacity: 0.28;
  }
  64% {
    opacity: 0.12;
  }
  82%,
  100% {
    opacity: 0;
    transform: translateX(128vw);
  }
}

html {
  background: var(--bg);
  scrollbar-color: #aeb8c0 transparent;
  scrollbar-width: thin;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 14px;
  animation: none;
}

body::before,
body::after {
  content: none;
}

button,
input,
textarea,
select {
  letter-spacing: 0;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

::selection {
  background: #cce7ef;
  color: var(--ink);
}

/* App shell and navigation */

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 78px;
  height: 100vh;
  padding: 16px 11px;
  gap: 18px;
  overflow: hidden;
  border-right: 1px solid var(--sidebar-line);
  background: var(--sidebar);
  box-shadow: none;
  transition: width 220ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 220ms ease;
}

.sidebar::before,
.sidebar::after {
  content: none;
}

.sidebar:hover,
.sidebar:focus-within,
.sidebar.sidebar-open {
  width: 258px;
  padding: 16px 11px;
  background: var(--sidebar);
  box-shadow: 18px 0 42px rgba(20, 27, 32, 0.18);
}

.brand {
  width: 234px;
  min-width: 234px;
  height: 50px;
  padding: 4px 7px;
  gap: 12px;
}

.brand-logo,
.sidebar:hover .brand-logo,
.sidebar:focus-within .brand-logo,
.sidebar.sidebar-open .brand-logo {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: none;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 160ms ease, transform 180ms ease;
}

.sidebar:hover .brand-copy,
.sidebar:focus-within .brand-copy,
.sidebar.sidebar-open .brand-copy {
  opacity: 1;
  transform: translateX(0);
}

.brand strong,
.brand span,
.sidebar:hover .brand strong,
.sidebar:hover .brand span,
.sidebar:focus-within .brand strong,
.sidebar:focus-within .brand span,
.sidebar.sidebar-open .brand strong,
.sidebar.sidebar-open .brand span {
  opacity: 1;
  transform: none;
  white-space: nowrap;
}

.brand strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 13px;
  text-overflow: ellipsis;
}

.brand span {
  margin-top: 2px;
  color: #9faab2;
  font-size: 11px;
}

.nav-list {
  width: 234px;
  min-width: 234px;
  gap: 3px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0 8px;
  scrollbar-width: none;
}

.nav-list::-webkit-scrollbar {
  display: none;
}

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  align-items: center;
  width: 100%;
  min-height: 43px;
  padding: 0 8px;
  gap: 7px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #bac3ca;
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.nav-item::before {
  content: none;
}

.nav-item > svg {
  width: 19px;
  height: 19px;
  margin: auto;
  color: #97a5ae;
  transition: color 140ms ease, transform 160ms ease;
}

.nav-item > span {
  overflow: hidden;
  opacity: 0;
  text-overflow: ellipsis;
  transform: translateX(-4px);
  transition: opacity 140ms ease, transform 160ms ease;
  white-space: nowrap;
}

.nav-item .nav-chevron {
  width: 14px;
  height: 14px;
  opacity: 0;
}

.sidebar:hover .nav-item > span,
.sidebar:focus-within .nav-item > span,
.sidebar.sidebar-open .nav-item > span,
.sidebar:hover .nav-item .nav-chevron,
.sidebar:focus-within .nav-item .nav-chevron,
.sidebar.sidebar-open .nav-item .nav-chevron {
  opacity: 1;
  transform: translateX(0);
}

.nav-item:hover {
  border-color: #3c4851;
  background: #293139;
  color: #ffffff;
  box-shadow: none;
  transform: none;
}

.nav-item:hover > svg {
  color: #ffffff;
  transform: scale(1.05);
}

.nav-item.active {
  border-color: #47677b;
  background: #1a425b;
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--accent);
  transform: none;
}

.nav-item.active > svg {
  color: #ff9b54;
}

.nav-group {
  position: relative;
}

.nav-submenu {
  position: static;
  display: none;
  gap: 2px;
  margin: 3px 0 5px 42px;
  padding: 4px 0 4px 10px;
  border: 0;
  border-left: 1px solid #46515a;
  background: transparent;
  box-shadow: none;
}

.sidebar:hover .nav-group:hover .nav-submenu,
.sidebar:focus-within .nav-group:focus-within .nav-submenu,
.sidebar.sidebar-open .nav-group:hover .nav-submenu {
  display: grid;
  animation: ui-enter 140ms ease both;
}

.nav-submenu button {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #aeb8bf;
  font-size: 11px;
  font-weight: 650;
  text-align: left;
}

.nav-submenu button svg {
  width: 15px;
  height: 15px;
}

.nav-submenu button:hover {
  border: 0;
  background: #303941;
  color: #ffffff;
  box-shadow: none;
  transform: none;
}

.sidebar-footer {
  position: relative;
  z-index: 1;
  display: grid;
  width: 234px;
  min-width: 234px;
  gap: 4px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #343d44;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.sidebar-settings-item {
  margin-bottom: 4px;
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-settings-item.active {
  border-color: #47677b;
  background: #1a425b;
}

.sidebar:not(:hover):not(:focus-within):not(.sidebar-open) .sidebar-footer {
  width: 56px;
  min-width: 56px;
}

.sidebar:not(:hover):not(:focus-within):not(.sidebar-open) .sidebar-footer > :not(.sidebar-settings-item) {
  display: none !important;
}

.sidebar:not(:hover):not(:focus-within):not(.sidebar-open) .sidebar-settings-item {
  width: 56px;
  min-width: 56px;
  grid-template-columns: 40px;
}

.sidebar-footer .secondary-button,
.sidebar-footer .import-label {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  min-height: 38px;
  padding: 0 8px;
  gap: 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #aeb8bf;
  box-shadow: none;
  font-size: 11px;
  text-align: left;
}

.sidebar-footer svg {
  width: 17px;
  height: 17px;
  margin: auto;
}

.sidebar-footer button span,
.sidebar-footer label span,
.save-status {
  opacity: 0;
  transition: opacity 140ms ease;
  white-space: nowrap;
}

.sidebar:hover .sidebar-footer button span,
.sidebar:hover .sidebar-footer label span,
.sidebar:hover .save-status,
.sidebar:focus-within .sidebar-footer button span,
.sidebar:focus-within .sidebar-footer label span,
.sidebar:focus-within .save-status,
.sidebar.sidebar-open .sidebar-footer button span,
.sidebar.sidebar-open .sidebar-footer label span,
.sidebar.sidebar-open .save-status {
  opacity: 1;
}

.sidebar-footer .secondary-button:hover,
.sidebar-footer .import-label:hover {
  border: 0;
  background: #2d363d;
  color: #ffffff;
  box-shadow: none;
  transform: none;
}

.save-status {
  overflow: hidden;
  padding: 6px 10px 0 55px;
  color: #7f8c95;
  font-size: 10px;
  text-overflow: ellipsis;
}

.sidebar-backdrop,
.mobile-menu-button {
  display: none;
}

/* Top bar and workspace */

.main {
  min-width: 0;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px 24px;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 0 rgba(21, 31, 39, 0.02);
  backdrop-filter: blur(14px);
}

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

.topbar-logo {
  width: 108px;
  max-width: none;
  height: 36px;
  margin: 0;
  padding: 2px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
  object-position: left center;
}

.topbar #viewTitle {
  display: block;
  overflow: hidden;
  margin: 0;
  padding-left: 14px;
  border-left: 1px solid var(--line);
  color: var(--ink);
  font-size: 17px;
  font-weight: 720;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  gap: 8px;
}

.search-box {
  width: min(390px, 36vw);
  min-width: 220px;
  min-height: 40px;
  padding: 0 11px;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  box-shadow: none;
}

.search-box:focus-within {
  border-color: #e0a174;
  background: #ffffff;
  box-shadow: var(--focus-ring);
  transform: none;
}

.search-box svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  color: #778690;
}

.search-box input {
  padding: 9px 0;
  color: var(--ink);
  font-size: 13px;
}

.search-box input::placeholder {
  color: #89959e;
}

.workspace {
  width: min(100%, 1720px);
  margin: 0 auto;
  padding: 22px 24px 46px;
  animation: ui-enter 220ms ease both;
}

/* Typography and commands */

.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--ink);
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  font-size: 14px;
  line-height: 1.35;
}

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

.primary-button,
.secondary-button,
.danger-button,
.import-label,
.icon-button,
.view-toggle button,
.invoice-status-filter button,
.document-action-trigger {
  min-height: 38px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 680;
  box-shadow: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.primary-button,
.topbar .primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 13px;
  gap: 7px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: none;
}

.primary-button svg,
.secondary-button svg,
.danger-button svg {
  width: 16px;
  height: 16px;
}

.primary-button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  box-shadow: none;
  transform: translateY(-1px);
}

.secondary-button,
.import-label,
.icon-button,
.document-action-trigger {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--ink-soft);
  box-shadow: none;
}

.secondary-button:hover,
.import-label:hover,
.icon-button:hover,
.document-action-trigger:hover {
  border-color: #9fb0ba;
  background: var(--panel-soft);
  color: var(--ink);
  box-shadow: none;
  transform: translateY(-1px);
}

.danger-button {
  border: 1px solid #e1bfc1;
  background: #fffafa;
  color: var(--danger);
}

.danger-button:hover {
  border-color: #cb8c90;
  background: var(--coral-soft);
  box-shadow: none;
}

.icon-button {
  width: 38px;
  padding: 0;
}

/* Page headers and dashboard */

.page-hero,
.dashboard-hero,
.clients-hero,
.settings-hero,
.accountant-hero,
.integration-panel {
  position: relative;
  min-height: 0;
  margin: 0 0 18px;
  padding: 4px 0 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}

.page-hero::before,
.page-hero::after,
.dashboard-hero::before,
.dashboard-hero::after,
.clients-hero::before,
.clients-hero::after,
.settings-hero::before,
.settings-hero::after,
.accountant-hero::before,
.accountant-hero::after,
.integration-panel::before,
.integration-panel::after {
  content: none;
}

.page-hero h2,
.page-hero h3,
.dashboard-hero h2,
.clients-hero h2,
.settings-hero h2,
.accountant-hero h2 {
  margin: 2px 0 4px;
  color: var(--ink);
  font-size: 22px;
}

.page-hero .eyebrow,
.dashboard-hero .eyebrow,
.clients-hero .eyebrow {
  color: var(--accent-strong);
}

.page-hero p:not(.eyebrow),
.dashboard-hero p:not(.eyebrow),
.clients-hero p:not(.eyebrow) {
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

.clients-hero .muted,
.clients-hero p.muted {
  color: #405568;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.dashboard-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.dashboard-hero-copy {
  max-width: 720px;
}

.dashboard-hero-side {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 650px;
}

.dashboard-hero-side span {
  display: inline-flex;
  align-items: baseline;
  min-height: 0;
  padding: 6px 9px;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #ffffff;
  color: var(--muted);
  font-size: 10px;
}

.dashboard-hero-side strong {
  color: var(--ink);
  font-size: 13px;
}

.dashboard-privacy-toolbar {
  justify-content: flex-end;
  min-height: 32px;
  margin: -10px 0 10px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.dashboard-privacy-toolbar > span {
  font-size: 10px;
}

.dashboard-privacy-button {
  width: 30px;
  height: 30px;
  border-color: var(--line);
  background: #ffffff;
  box-shadow: none;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  align-items: stretch;
  gap: 10px;
  margin-bottom: 18px;
}

.dashboard-metrics .stat-card,
.stat-card {
  position: relative;
  min-height: 112px;
  padding: 14px 14px 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.dashboard-metrics .stat-card::before,
.dashboard-metrics .stat-card::after,
.stat-card::before,
.stat-card::after {
  content: none;
}

.dashboard-metrics .stat-card:hover,
.stat-card:hover {
  border-color: #b7c5cd;
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.dashboard-metrics .stat-card > span,
.stat-card > span {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.dashboard-metrics .stat-card > strong,
.stat-card > strong {
  color: var(--ink);
  font-size: 25px;
  font-weight: 740;
  line-height: 1.1;
}

.dashboard-metrics .stat-card > small,
.stat-card > small {
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.stat-card.metric-cyan {
  border-top: 3px solid var(--cyan);
}

.stat-card.metric-blue {
  border-top: 3px solid #2f7394;
}

.stat-card.metric-pink {
  border-top: 3px solid var(--coral);
}

.stat-card.metric-green {
  border-top: 3px solid var(--green);
}

.stat-card.metric-violet {
  border-top: 3px solid var(--violet);
}

.stat-card.metric-amber {
  border-top: 3px solid var(--accent);
}

.dashboard-financial-breakdown {
  margin-top: 8px;
  gap: 3px;
}

.dashboard-financial-breakdown small {
  font-size: 9px;
}

.annual-comparison-band {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.annual-summary {
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
}

.annual-summary-item {
  border: 0;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

.annual-chart {
  min-height: 220px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.modern-dashboard-grid,
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 14px;
}

/* Panels, cards and detail pages */

.panel,
.record-card,
.client-detail-card,
.client-section,
.client-intel-panel,
.portal-panel,
.accountant-alert,
.accountant-save-card,
.accountant-row,
.machine-card,
.grouped-panel {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.panel {
  padding: 17px;
}

.panel:hover,
.record-card:hover,
.client-name-card:hover,
.machine-card:hover,
.client-section:hover {
  border-color: #c7d0d6;
  box-shadow: var(--shadow-soft);
  transform: none;
}

.panel-header {
  align-items: center;
  min-height: 42px;
  margin-bottom: 12px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  font-size: 16px;
}

.record-grid {
  gap: 10px;
}

.record-card {
  padding: 14px;
}

.record-header {
  gap: 10px;
}

.record-icon {
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.meta-list {
  gap: 6px;
}

.meta-list span {
  color: var(--muted);
  font-size: 11px;
}

.client-type-breakdown {
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
}

.client-type-card {
  border: 0;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

.client-section-navigation,
.client-quick-menu {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.client-section-navigation button,
.client-quick-menu button {
  border-radius: 5px;
}

.machine-card {
  padding: 14px;
}

/* Tables and list controls */

.list-toolbar {
  align-items: center;
  margin-bottom: 12px;
  padding: 0;
}

.toolbar-actions {
  gap: 7px;
}

.view-toggle,
.invoice-status-filter {
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: none;
}

.view-toggle button,
.invoice-status-filter button {
  min-height: 31px;
  padding: 6px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.view-toggle button.active,
.invoice-status-filter button.active,
.invoice-status-filter .filter-all.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

.invoice-status-filter .filter-paid.active,
.inventory-availability-filter .filter-available.active {
  background: var(--green-soft);
  color: var(--green);
}

.invoice-status-filter .filter-unpaid.active {
  background: var(--amber-soft);
  color: #805414;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.table-wrap table,
table {
  border-radius: 0;
  background: #ffffff;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-strong);
  background: #f5f7f8;
  color: #53616c;
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid #e8ecef;
  background: #ffffff;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover td {
  background: #f8fafb;
}

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

.table-wrap tr.admin-invoice-paid > td {
  background: #edf8f1;
}

.table-wrap tr.admin-invoice-sent > td {
  background: #fff8e8;
}

.table-wrap tr.admin-invoice-credit > td,
.table-wrap tr.expiration-expired > td {
  background: #fff0ef;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--panel-muted);
  box-shadow: none;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 780;
}

.badge.success {
  border-color: #c7e4d3;
  background: var(--green-soft);
  color: var(--green);
}

.badge.warning {
  border-color: #edd8ac;
  background: var(--amber-soft);
  color: #805414;
}

.badge.danger {
  border-color: #ebc6c3;
  background: var(--coral-soft);
  color: var(--danger);
}

.document-action-menu {
  position: relative;
}

.document-action-trigger {
  min-height: 32px;
  padding: 5px 9px;
  list-style: none;
}

.document-action-list {
  min-width: 210px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.document-action-menu[open] .document-action-list {
  animation: ui-enter 120ms ease both;
}

.action-button {
  min-height: 33px;
  border: 0;
  border-radius: 5px;
  background: #ffffff;
  box-shadow: none;
  font-size: 11px;
}

.action-button:hover {
  border: 0;
  background: var(--panel-soft);
  transform: none;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--muted);
}

/* Forms and dialogs */

.modal {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: transparent;
  box-shadow: var(--shadow);
}

.modal[open] {
  animation: modal-enter 180ms ease both;
}

.modal::backdrop {
  background: rgba(24, 31, 37, 0.58);
  backdrop-filter: blur(5px);
}

.modal-panel {
  padding: 20px;
  border: 0;
  background: #ffffff;
  box-shadow: none;
}

.modal-panel::before {
  content: none;
}

.modal-wide .modal-header,
.modal-wide .modal-actions {
  background: rgba(255, 255, 255, 0.97);
}

.modal-header {
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  font-size: 18px;
}

.modal-actions {
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.form-grid {
  gap: 13px;
}

.field {
  gap: 6px;
}

.field label {
  color: #4f5e69;
  font-size: 11px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select,
.copy-line input {
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: none;
}

.field textarea {
  min-height: 96px;
  line-height: 1.45;
}

.field input:hover,
.field textarea:hover,
.field select:hover {
  border-color: #abb8c0;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.copy-line input:focus {
  border-color: #de9b6b;
  background: #ffffff;
  box-shadow: var(--focus-ring);
}

.field-disabled {
  opacity: 0.55;
}

.field-disabled input,
.field-disabled select,
.field-disabled textarea {
  background: #f0f2f4;
}

select {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, transparent 50%, #5d6b75 50%),
    linear-gradient(135deg, #5d6b75 50%, transparent 50%);
}

.quote-items-editor,
.sale-items-editor,
.invoice-tax-items {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.quote-items-head span,
.sale-items-head span {
  padding: 9px;
  background: #39444c;
  color: #ffffff;
  font-size: 10px;
}

.quote-product-cell {
  background: #ffffff;
}

.quote-product-cell > textarea {
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #ffffff;
}

.quote-items-row.is-total-row {
  border-top-color: var(--accent);
  background: var(--accent-soft);
}

.quote-items-row.is-total-row .quote-product-cell {
  background: var(--accent-soft);
}

/* Access and customer portal */

.locked-mode .app-shell {
  display: block;
}

.auth-shell,
.portal-auth,
.customer-auth {
  background: #0d3048;
}

.auth-shell::before,
.auth-shell::after {
  content: none;
}

.auth-backdrop {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(118deg, #f4f7f9 0%, #eef3f6 49.8%, #0d3048 50%, #0d3048 100%);
  pointer-events: none;
}

.auth-technical-grid {
  position: absolute;
  inset: -38% -18% -14% 34%;
  background-image:
    linear-gradient(rgba(137, 178, 198, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(137, 178, 198, 0.07) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.7;
  transform: perspective(700px) rotateX(58deg) translateY(18%);
  transform-origin: center bottom;
  animation: auth-grid-flow 10s linear infinite;
}

.auth-architecture {
  position: absolute;
  inset: 0;
  animation: auth-structure-drift 14s ease-in-out infinite;
}

.auth-architecture span {
  position: absolute;
  display: block;
  border: 1px solid rgba(129, 173, 196, 0.2);
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}

.auth-architecture span:nth-child(1) {
  top: 8%;
  right: -7vw;
  width: 42vw;
  height: 42vw;
}

.auth-architecture span:nth-child(2) {
  top: 20%;
  right: -2vw;
  width: 31vw;
  height: 31vw;
}

.auth-architecture span:nth-child(3) {
  top: 32%;
  right: 4vw;
  width: 20vw;
  height: 20vw;
}

.auth-data-lines {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.auth-data-lines i {
  position: absolute;
  left: 0;
  width: 24vw;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 122, 34, 0.75), transparent);
  opacity: 0;
  transform-origin: left center;
  animation: auth-data-travel 8s linear infinite;
}

.auth-data-lines i:nth-child(1) {
  top: 18%;
}

.auth-data-lines i:nth-child(2) {
  top: 34%;
  animation-delay: -5.6s;
}

.auth-data-lines i:nth-child(3) {
  top: 52%;
  animation-delay: -2.8s;
}

.auth-data-lines i:nth-child(4) {
  top: 69%;
  animation-delay: -7s;
}

.auth-data-lines i:nth-child(5) {
  top: 84%;
  animation-delay: -4.2s;
}

.auth-sweep {
  position: absolute;
  top: -15%;
  bottom: -15%;
  left: -20vw;
  width: 13vw;
  background: linear-gradient(90deg, transparent, rgba(244, 122, 34, 0.16), transparent);
  opacity: 0;
  transform: skewX(-10deg);
  animation: auth-sweep-travel 12s ease-in-out infinite;
}

.auth-card,
.admin-login-card,
.customer-login-card {
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(20px);
}

.auth-card::before,
.admin-login-card::before,
.customer-login-card::before {
  background: var(--accent);
}

.admin-auth {
  grid-template-columns: minmax(320px, 430px);
  justify-content: start;
  padding-left: clamp(30px, 9vw, 150px);
}

.admin-auth .auth-project-credit {
  width: min(430px, calc(100vw - 36px));
}

.auth-logo-stage {
  border-radius: 7px;
  background: #ffffff;
  animation: none;
}

.auth-logo-stage::before,
.auth-logo-stage > span {
  display: none;
}

.auth-logo-stage .auth-logo,
.auth-logo-stage .portal-logo {
  mix-blend-mode: normal;
}

.admin-auth .auth-project-credit,
.admin-auth .auth-project-credit strong,
.admin-auth .auth-project-credit span {
  color: var(--ink);
  text-shadow: none;
}

.auth-project-credit {
  color: #ffffff;
}

.portal-app {
  background: var(--bg);
}

.portal-menu {
  border-right: 1px solid var(--sidebar-line);
  background: var(--sidebar);
}

.portal-menu-item {
  border-radius: 6px;
}

.portal-menu-item:hover,
.portal-menu-item.active {
  background: var(--sidebar-soft);
  transform: none;
}

/* Tablet */

@media (max-width: 1180px) {
  .dashboard-metrics {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .search-box {
    width: min(320px, 34vw);
  }

  .topbar-logo {
    width: 88px;
  }
}

/* Mobile app layout */

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
    background: var(--bg);
    -webkit-tap-highlight-color: transparent;
  }

  body.mobile-menu-open {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .sidebar,
  .sidebar:hover,
  .sidebar:focus-within,
  .sidebar.sidebar-open {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    display: flex;
    width: min(290px, 86vw);
    height: 100dvh;
    padding: 14px 11px calc(16px + env(safe-area-inset-bottom));
    border: 0;
    border-right: 1px solid var(--sidebar-line);
    border-radius: 0;
    background: var(--sidebar);
    box-shadow: 22px 0 54px rgba(14, 20, 24, 0.3);
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translateX(-102%);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 180ms ease;
  }

  .sidebar.sidebar-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: block;
    border: 0;
    background: rgba(24, 31, 37, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    backdrop-filter: blur(3px);
  }

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

  .brand {
    display: flex;
  }

  .brand-copy,
  .sidebar .brand-copy,
  .sidebar .nav-item > span,
  .sidebar .nav-item .nav-chevron,
  .sidebar .sidebar-footer button span,
  .sidebar .sidebar-footer label span,
  .sidebar .save-status {
    opacity: 1;
    transform: none;
  }

  .nav-list {
    display: grid;
    width: 100%;
    min-width: 0;
    height: auto;
    padding-right: 3px;
    gap: 3px;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-type: none;
  }

  .nav-group {
    display: block !important;
  }

  .nav-group-toggle {
    display: grid !important;
  }

  .nav-item {
    display: grid;
    width: 100%;
    min-height: 43px;
    border-radius: 7px;
    color: #bac3ca;
  }

  .nav-submenu,
  .sidebar .nav-submenu {
    display: grid !important;
    margin-left: 43px;
  }

  .nav-submenu button {
    width: 100%;
    min-height: 34px;
    justify-content: flex-start;
    border-radius: 6px;
  }

  .sidebar-footer {
    display: grid;
    width: 100%;
    min-width: 0;
  }

  .mobile-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    color: var(--ink-soft);
  }

  .mobile-menu-button svg {
    width: 19px;
    height: 19px;
  }

  .topbar {
    min-height: 62px;
    padding: 9px 12px;
    gap: 8px;
  }

  .topbar-identity {
    gap: 9px;
  }

  .topbar-logo {
    width: 70px;
    height: 30px;
  }

  .topbar #viewTitle {
    max-width: 110px;
    padding-left: 9px;
    font-size: 14px;
  }

  .topbar-actions {
    margin: 0;
    gap: 6px;
  }

  .search-box {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0 10px;
    overflow: hidden;
    transition: width 180ms ease;
  }

  .search-box:focus-within {
    position: absolute;
    right: 12px;
    width: calc(100vw - 74px);
    z-index: 3;
  }

  .search-box input {
    min-width: 240px;
  }

  .topbar .primary-button,
  .topbar .secondary-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
  }

  .topbar .primary-button span,
  .topbar .secondary-button span {
    display: none;
  }

  .admin-logout-top {
    display: none;
  }

  .workspace {
    width: 100%;
    padding: 15px 12px calc(34px + env(safe-area-inset-bottom));
  }

  .page-hero,
  .dashboard-hero,
  .clients-hero,
  .settings-hero,
  .accountant-hero {
    display: block;
    margin-bottom: 14px;
    padding: 2px 0 14px;
  }

  .page-hero h2,
  .dashboard-hero h2,
  .clients-hero h2 {
    font-size: 19px;
  }

  .dashboard-hero-side {
    justify-content: flex-start;
    width: 100%;
    margin-top: 10px;
  }

  .dashboard-hero-side span {
    min-height: 0;
    padding: 5px 7px;
  }

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

  .dashboard-metrics .stat-card,
  .stat-card {
    min-height: 102px;
    padding: 12px;
  }

  .dashboard-metrics .stat-card > strong,
  .stat-card > strong {
    font-size: 20px;
    overflow-wrap: anywhere;
  }

  .modern-dashboard-grid,
  .dashboard-grid,
  .accountant-grid,
  .client-list-page,
  .support-board,
  .machine-list-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .panel,
  .record-card,
  .client-section,
  .client-detail-card,
  .machine-card,
  .annual-comparison-band {
    min-width: 0;
    max-width: 100%;
    padding: 13px;
  }

  .list-toolbar,
  .panel-header,
  .annual-comparison-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: flex-start;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    flex-wrap: nowrap;
  }

  .view-toggle,
  .invoice-status-filter {
    flex: 0 0 auto;
  }

  .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border-radius: 7px;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 760px;
  }

  th,
  td {
    padding: 9px 10px;
  }

  .modal,
  .modal.modal-medium,
  .modal.modal-wide,
  .modal.modal-document-wide {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .modal-panel {
    width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    padding: 14px 12px calc(86px + env(safe-area-inset-bottom));
    border-radius: 0;
    overflow-y: auto;
  }

  .modal-wide .modal-header,
  .modal-wide .modal-actions {
    background: rgba(255, 255, 255, 0.98);
  }

  .modal-actions,
  .modal-wide .modal-actions {
    position: sticky;
    bottom: calc(-86px - env(safe-area-inset-bottom));
    z-index: 8;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: calc(100% + 24px);
    margin: 18px -12px calc(-86px - env(safe-area-inset-bottom));
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
  }

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

  .field,
  .field.full {
    grid-column: 1;
  }

  .quote-items-editor,
  .sale-items-editor,
  .invoice-tax-items {
    width: 100%;
    max-width: 100%;
    overflow: auto;
  }

  .auth-shell {
    min-height: 100dvh;
    padding: 18px 12px;
  }

  .admin-auth {
    justify-content: center;
    padding-left: 12px;
  }

  .admin-auth .auth-project-credit,
  .admin-auth .auth-project-credit strong,
  .admin-auth .auth-project-credit span {
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(4, 23, 33, 0.42);
  }

  .auth-backdrop {
    background: #0d3048;
  }

  .auth-technical-grid {
    inset: -20% -80% -8% -30%;
    opacity: 0.5;
  }

  .auth-architecture span:nth-child(1) {
    top: 8%;
    right: -35vw;
    width: 110vw;
    height: 110vw;
  }

  .auth-architecture span:nth-child(2) {
    top: 23%;
    right: -22vw;
    width: 82vw;
    height: 82vw;
  }

  .auth-architecture span:nth-child(3) {
    top: 36%;
    right: -8vw;
    width: 54vw;
    height: 54vw;
  }

  .auth-card,
  .admin-login-card,
  .customer-login-card {
    width: min(100%, 430px);
    padding: 18px;
  }
}

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

  .topbar #viewTitle {
    max-width: 96px;
    padding-left: 0;
    border-left: 0;
  }

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

  .dashboard-metrics .stat-card {
    min-height: 90px;
  }
}

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

/*
 * Final typography pass
 * Keeps legacy white-text rules from becoming unreadable on the new light UI.
 */
body {
  color: #10263b;
  font-family: Arial, "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: 14px;
}

.main,
.workspace,
.modal-panel,
.portal-app,
.panel,
.record-card,
.client-section,
.client-detail-card,
.machine-card,
.annual-comparison-band {
  color: #10263b;
}

.workspace p,
.modal-panel p,
.portal-app p,
.panel p,
.record-card p,
.client-section p,
.client-detail-card p,
.machine-card p,
.annual-comparison-band p {
  color: #334b5e;
  font-size: 14px;
  line-height: 1.55;
}

.workspace .muted,
.modal-panel .muted,
.portal-app .muted,
.panel .muted,
.record-card .muted,
.client-section .muted,
.client-detail-card .muted,
.machine-card .muted,
.annual-comparison-band .muted,
.clients-hero .muted,
.clients-hero p.muted {
  color: #405669 !important;
  font-size: 14px !important;
  font-weight: 500;
  line-height: 1.55;
  opacity: 1 !important;
}

.workspace small,
.modal-panel small,
.portal-app small,
.panel small,
.record-card small,
.client-section small {
  color: #4b6173;
  font-size: 12px;
  line-height: 1.45;
}

.eyebrow,
.workspace .eyebrow,
.modal-panel .eyebrow,
.portal-app .eyebrow {
  color: #b8500a;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.page-hero h2,
.dashboard-hero h2,
.clients-hero h2,
.settings-hero h2,
.accountant-hero h2 {
  color: #10263b !important;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.25;
}

.page-hero p:not(.eyebrow),
.dashboard-hero p:not(.eyebrow),
.clients-hero p:not(.eyebrow),
.settings-hero p:not(.eyebrow),
.accountant-hero p:not(.eyebrow) {
  color: #405669 !important;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.55;
}

.panel-header h2,
.panel-header h3,
.client-section h3,
.client-detail-card h3,
.record-card h3,
.machine-card h3,
.modal-header h2,
.modal-header h3 {
  color: #10263b;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
}

.field label,
.modal-panel label,
.filter-field label,
.settings-field label {
  color: #253d50;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.field input,
.field textarea,
.field select,
.modal-panel input,
.modal-panel textarea,
.modal-panel select {
  color: #10263b;
  font-size: 14px;
  line-height: 1.45;
}

.field input::placeholder,
.field textarea::placeholder,
.modal-panel input::placeholder,
.modal-panel textarea::placeholder {
  color: #738391;
  opacity: 1;
}

.primary-button,
.secondary-button,
.danger-button,
.import-label,
.view-toggle button,
.invoice-status-filter button,
.document-action-trigger {
  font-size: 13px;
  line-height: 1.25;
}

.nav-item {
  font-size: 13px;
}

@media (min-width: 761px) {
  .nav-group {
    position: relative;
  }

  .nav-submenu,
  .sidebar:hover .nav-group:hover .nav-submenu,
  .sidebar:focus-within .nav-group:focus-within .nav-submenu,
  .sidebar.sidebar-open .nav-group:hover .nav-submenu {
    left: 50px;
    margin: 0;
    position: absolute;
    top: 4px;
    width: 176px;
    z-index: 30;
  }

  .sidebar:hover .nav-group:hover .nav-submenu,
  .sidebar:focus-within .nav-group:focus-within .nav-submenu,
  .sidebar.sidebar-open .nav-group:hover .nav-submenu {
    border: 1px solid rgba(155, 219, 231, 0.2);
    border-radius: 7px;
    background: #172d3a;
    box-shadow: 0 14px 30px rgba(4, 23, 33, 0.3);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 5px;
  }

  .nav-submenu button {
    justify-content: center;
    min-width: 0;
    padding: 0 6px;
  }

  .nav-submenu button svg {
    display: none;
  }
}

.nav-submenu button,
.sidebar-footer button,
.sidebar-footer .import-label {
  font-size: 12px;
}

.settings-layout .settings-save-bar {
  bottom: auto;
  position: static;
  z-index: auto;
}

.topbar [hidden],
.sidebar [hidden] {
  display: none !important;
}

label.checkbox-field {
  align-items: center;
  display: flex;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
}

label.checkbox-field input[type="checkbox"] {
  flex: 0 0 18px;
  height: 18px;
  margin: 0;
  min-height: 18px;
  padding: 0;
  width: 18px;
}

table {
  color: #20384b;
}

th {
  color: #3b5264;
  font-size: 11px;
  font-weight: 700;
}

td {
  color: #263f52;
  font-size: 13px;
  line-height: 1.45;
}

.meta-list span,
.record-meta,
.client-meta,
.machine-meta {
  color: #455d70;
  font-size: 12px;
  line-height: 1.45;
}

.badge,
.status-badge,
.invoice-status,
.quote-status {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

.save-status {
  color: #aeb9c1;
  font-size: 11px;
}

.dashboard-hero-side span,
.dashboard-privacy-toolbar > span,
.dashboard-metrics .stat-card > span,
.stat-card > span {
  font-size: 11px;
}

.dashboard-metrics .stat-card > small,
.stat-card > small {
  font-size: 12px;
  line-height: 1.4;
}

.dashboard-financial-breakdown small {
  font-size: 11px;
}

.action-button {
  font-size: 12px;
}

.sale-items-head span,
.quote-items-head span,
.invoice-items-head span {
  font-size: 11px;
  line-height: 1.35;
}

.client-type-card,
.client-type-card.client-type-blue,
.client-type-card.client-type-amber {
  background: #ffffff;
  color: #10263b;
}

.client-type-card h3,
.client-type-card strong {
  color: #10263b !important;
}

.client-type-card span,
.client-type-card p {
  color: #405669 !important;
  font-size: 13px;
  opacity: 1;
}

.support-command,
.client-command-hero {
  border: 1px solid #dce3e8;
  border-radius: 7px;
  background: #ffffff;
  color: #10263b;
  box-shadow: var(--shadow-soft);
}

.support-command::before,
.support-command::after,
.client-command-hero::before,
.client-command-hero::after {
  content: none;
}

.support-command h2,
.support-command h3,
.client-command-hero h2,
.client-command-hero h3,
.client-command-main h3 {
  color: #10263b !important;
}

.support-command p,
.client-command-hero p,
.client-command-main p {
  color: #405669 !important;
  font-size: 14px;
  line-height: 1.55;
}

.support-command .eyebrow,
.client-command-hero .eyebrow,
.client-command-main .eyebrow {
  color: #b8500a !important;
}

.client-command-avatar {
  background: #0d3048;
  color: #ffffff;
}

.client-hero-tags .badge {
  border-color: #f0c7a8;
  background: #fff0e5;
  color: #9f4308;
}

.auth-card,
.admin-login-card,
.customer-login-card {
  color: #10263b;
}

.auth-card h1,
.auth-card h2,
.auth-card h3,
.admin-login-card h1,
.admin-login-card h2,
.customer-login-card h1,
.customer-login-card h2 {
  color: #10263b;
}

.auth-card p,
.admin-login-card p,
.customer-login-card p {
  color: #405669;
  font-size: 14px;
  line-height: 1.5;
}

.auth-brand-mark {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  margin: 0 auto 4px;
}

.auth-brand-mark .auth-logo,
.auth-brand-mark .portal-logo,
.admin-login-card .auth-brand-mark .auth-logo,
.customer-login-card .auth-brand-mark .portal-logo {
  display: block;
  width: 100%;
  max-width: 78px;
  height: 100%;
  max-height: 78px;
  margin: 0;
  object-fit: contain;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 10px 18px rgba(8, 35, 52, 0.2));
}

@media (max-width: 480px) {
  .auth-brand-mark {
    width: 66px;
    height: 66px;
  }

  .auth-brand-mark .auth-logo,
  .auth-brand-mark .portal-logo,
  .admin-login-card .auth-brand-mark .auth-logo,
  .customer-login-card .auth-brand-mark .portal-logo {
    max-width: 66px;
    max-height: 66px;
  }
}

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

  .page-hero h2,
  .dashboard-hero h2,
  .clients-hero h2,
  .settings-hero h2,
  .accountant-hero h2 {
    font-size: 20px;
  }

  .workspace p,
  .modal-panel p,
  .portal-app p,
  .workspace .muted,
  .modal-panel .muted,
  .portal-app .muted {
    font-size: 13px !important;
  }

  th {
    font-size: 11px;
  }

  td {
    font-size: 13px;
  }
}

/* Service desk: dedicated high-contrast header */
.page-hero.support-command {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 22px 24px;
  overflow: hidden;
  border: 1px solid #214d67;
  border-left: 5px solid #f47a22;
  border-radius: 7px;
  background: #0d3048;
  color: #ffffff;
  box-shadow: 0 12px 30px rgba(13, 48, 72, 0.16);
}

.page-hero.support-command .eyebrow {
  margin: 0 0 4px;
  color: #ffb27b !important;
  font-size: 11px;
  font-weight: 700;
}

.page-hero.support-command h2 {
  margin: 0 0 5px;
  color: #ffffff !important;
  font-size: 23px;
  font-weight: 700;
}

.page-hero.support-command p:not(.eyebrow) {
  max-width: 720px;
  margin: 0;
  color: #dce8ef !important;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.55;
}

.page-hero.support-command .primary-button {
  flex: 0 0 auto;
  border-color: #f47a22;
  background: #f47a22;
  color: #ffffff;
}

.page-hero.support-command .primary-button:hover {
  border-color: #ff9346;
  background: #ff9346;
}

@media (max-width: 760px) {
  .page-hero.support-command {
    display: block;
    padding: 18px;
  }

  .page-hero.support-command h2 {
    font-size: 20px;
  }

  .page-hero.support-command p:not(.eyebrow) {
    font-size: 13px !important;
  }

  .page-hero.support-command .primary-button {
    width: 100%;
    margin-top: 14px;
  }
}

/* Unified section headers */
.page-hero:not(.support-command) {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 0;
  margin: 0 0 18px;
  padding: 22px 24px;
  overflow: hidden;
  border: 1px solid #214d67;
  border-left: 5px solid #f47a22;
  border-radius: 7px;
  background: #0d3048;
  color: #ffffff;
  box-shadow: 0 12px 30px rgba(13, 48, 72, 0.16);
}

.page-hero:not(.support-command)::before,
.page-hero:not(.support-command)::after {
  content: none;
}

.page-hero:not(.support-command) .eyebrow {
  margin: 0 0 4px;
  color: #ffb27b !important;
  font-size: 11px;
  font-weight: 700;
}

.page-hero:not(.support-command) h2,
.page-hero:not(.support-command) h3 {
  margin: 0 0 5px;
  color: #ffffff !important;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.25;
}

.page-hero:not(.support-command) p:not(.eyebrow),
.page-hero:not(.support-command) .muted {
  max-width: 760px;
  margin: 0;
  color: #dce8ef !important;
  font-size: 14px !important;
  font-weight: 500;
  line-height: 1.55;
}

.page-hero:not(.support-command) .secondary-button,
.page-hero:not(.support-command) .document-action-trigger,
.page-hero:not(.support-command) .view-toggle,
.page-hero:not(.support-command) .invoice-status-filter,
.page-hero:not(.support-command) select {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.page-hero:not(.support-command) .secondary-button:hover,
.page-hero:not(.support-command) .document-action-trigger:hover {
  border-color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.page-hero:not(.support-command) .view-toggle button,
.page-hero:not(.support-command) .invoice-status-filter button {
  border-color: transparent;
  background: transparent;
  color: #dce8ef;
}

.page-hero:not(.support-command) .view-toggle button:hover,
.page-hero:not(.support-command) .invoice-status-filter button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.page-hero:not(.support-command) .view-toggle button.active,
.page-hero:not(.support-command) .invoice-status-filter button.active {
  background: #f47a22;
  color: #ffffff;
}

.page-hero:not(.support-command) select option {
  background: #ffffff;
  color: #10263b;
}

.page-hero:not(.support-command) .accountant-year-select {
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.1);
}

.page-hero:not(.support-command) .accountant-year-select span {
  color: #dce8ef;
}

.page-hero.dashboard-hero .dashboard-hero-side span {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #dce8ef;
}

.page-hero.dashboard-hero .dashboard-hero-side strong {
  color: #ffffff;
}

@media (max-width: 760px) {
  .page-hero:not(.support-command) {
    display: block;
    padding: 18px;
  }

  .page-hero:not(.support-command) h2,
  .page-hero:not(.support-command) h3 {
    font-size: 20px;
  }

  .page-hero:not(.support-command) p:not(.eyebrow),
  .page-hero:not(.support-command) .muted {
    display: block;
    font-size: 13px !important;
  }

  .page-hero.support-command p:not(.eyebrow) {
    display: block;
  }

  .page-hero:not(.support-command) .toolbar-actions,
  .page-hero:not(.support-command) .row-actions,
  .page-hero:not(.support-command) .dashboard-hero-side,
  .page-hero:not(.support-command) .accountant-year-select {
    width: 100%;
    margin-top: 14px;
  }

  .page-hero:not(.support-command) .toolbar-actions,
  .page-hero:not(.support-command) .row-actions,
  .page-hero:not(.support-command) .dashboard-hero-side {
    overflow-x: auto;
    padding-bottom: 2px;
  }
}

/* Final mobile authority: the internal app uses a drawer, never the old dock. */
@media (max-width: 760px) {
  .topbar {
    display: flex !important;
    flex-direction: row !important;
  }

  .topbar-actions {
    display: flex !important;
    flex-direction: row !important;
  }

  #quickAdd::before,
  .admin-logout-top::before {
    content: none !important;
    display: none !important;
  }

  .sidebar,
  .sidebar:hover,
  .sidebar:focus-within,
  .sidebar.sidebar-open {
    inset: 0 auto 0 0;
    width: min(300px, 88vw);
    height: 100dvh;
    border-radius: 0;
  }

  .nav-list {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    grid-template-columns: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  .nav-group {
    display: block !important;
    width: 100% !important;
  }

  .nav-group-toggle {
    display: grid !important;
  }

  .nav-item,
  .sidebar:hover .nav-item,
  .sidebar:focus-within .nav-item,
  .sidebar.sidebar-open .nav-item {
    display: grid !important;
    grid-template-columns: 32px minmax(0, 1fr) 18px !important;
    width: 100% !important;
    min-height: 43px !important;
    justify-content: initial !important;
    padding: 8px 10px !important;
    border-radius: 7px !important;
    text-align: left !important;
  }

  .nav-submenu,
  .sidebar .nav-submenu {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: auto !important;
    margin: 3px 0 5px 42px !important;
  }

  .nav-submenu button {
    width: 100% !important;
    justify-content: flex-start !important;
    padding: 7px 9px !important;
    text-align: left !important;
  }

  .record-card .meta-list > span {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 7px;
  }

  .record-card .meta-list > span > strong {
    flex: 0 0 88px;
    color: #20384b;
  }

  .search-box {
    position: relative;
    cursor: text;
  }

  .search-box input {
    width: 0 !important;
    min-width: 0 !important;
    padding-right: 0;
    padding-left: 0;
    opacity: 0;
    pointer-events: none;
  }

  .search-box.mobile-search-open {
    position: absolute;
    top: 8px;
    right: 10px;
    left: 10px;
    z-index: 20;
    display: flex;
    width: auto !important;
    min-width: 0 !important;
    height: 44px;
    padding: 0 12px;
    border-color: #e0a174;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(18, 35, 49, 0.18), var(--focus-ring);
  }

  .search-box.mobile-search-open input {
    width: 100% !important;
    min-width: 0 !important;
    padding: 9px 0;
    opacity: 1;
    pointer-events: auto;
  }

  .search-box.has-query:not(.mobile-search-open) {
    border-color: #f47a22;
    color: #f47a22;
  }
}
