:root {
  --nav: #202637;
  --nav-2: #f7f7f7;
  --ink: #333333;
  --muted: #707782;
  --line: #d7dbe2;
  --soft-line: #eceff3;
  --bg: #e8eaee;
  --panel: #ffffff;
  --blue: #2f78e6;
  --blue-soft: #edf5ff;
  --green: #32b653;
  --green-soft: #eefaf1;
  --red: #f04438;
  --red-soft: #fff3f2;
  --orange: #e48621;
  --orange-soft: #fff6e9;
  --shadow: 0 1px 6px rgba(39, 45, 58, 0.12);
  --shadow-soft: 0 1px 2px rgba(39, 45, 58, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans Thai", Arial, sans-serif;
  font-size: 15px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0) 42%),
    #eef2f7;
}

.login-panel {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.05fr);
  gap: 28px;
  padding: 30px;
  border: 1px solid #d7dfe9;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.16);
}

.login-brand {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--soft-line);
}

.login-brand strong {
  display: block;
  color: #111827;
  font-size: 1.25rem;
  font-weight: 900;
}

.login-brand span,
.login-copy p {
  color: var(--muted);
  font-weight: 700;
}

.login-copy {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 10px 6px 0;
}

.login-copy h1 {
  margin: 0;
  color: #111827;
  font-size: 2.3rem;
  line-height: 1.15;
}

.login-copy p {
  margin: 0;
  line-height: 1.7;
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  background: #f8fafc;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: #374151;
  font-weight: 850;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #cfd7e3;
  border-radius: 10px;
  background: #fff;
  color: #111827;
  font-weight: 750;
}

.login-error {
  margin: 0;
  color: var(--red);
  font-weight: 850;
}

.login-roles {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.login-roles button {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 13px;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #fff;
  color: #111827;
  text-align: left;
}

.login-roles button:hover {
  border-color: #93c5fd;
  background: var(--blue-soft);
}

.login-roles strong {
  color: #1d4ed8;
  font-weight: 900;
}

.login-roles span,
.login-roles small {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 750;
}

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

button {
  cursor: pointer;
}

button,
input,
select,
textarea {
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

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

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

.sidebar::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.sidebar::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd5e1;
}

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

.app-shell.sidebar-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px;
  background: #101828;
  border-right: 1px solid rgba(148, 163, 184, 0.24);
}

@media (min-width: 901px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: 248px;
    height: 100dvh;
  }

  .sidebar-collapsed .sidebar {
    width: 72px;
  }
}

.sidebar-backdrop {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 64px;
  padding: 6px 10px;
  margin-bottom: 14px;
  border: 1px solid rgba(226, 232, 240, 0.16);
  border-radius: 14px;
  background: #fff;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.18);
}

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

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: contain;
  object-position: center;
  background: transparent;
}

.brand-logo-full {
  width: 228px;
  max-width: 100%;
  height: 58px;
}

.login-brand .brand-logo-full {
  width: 214px;
  height: 56px;
}

.brand-logo-icon {
  width: 40px;
  height: 40px;
}

.brand-mark {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(145deg, #3478f6, #1d4ed8);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
  font-size: 0.95rem;
}

.nav-list {
  display: grid;
  gap: 4px;
  padding: 0;
}

.nav-item,
.subnav button {
  display: flex;
  width: 100%;
  align-items: center;
  border: 0;
  background: transparent;
  color: #3a3f48;
  text-align: left;
}

.nav-item {
  gap: 12px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #cbd5e1;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.08);
}

.nav-item:hover {
  color: #fff;
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(47, 120, 230, 0.95), rgba(37, 99, 235, 0.82));
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.22);
}

.nav-icon {
  display: inline-block;
  position: relative;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: currentColor;
}

.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}

.icon-home::before {
  left: 3px;
  top: 7px;
  width: 12px;
  height: 9px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 2px;
}

.icon-home::after {
  left: 4px;
  top: 2px;
  width: 10px;
  height: 10px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: rotate(45deg);
}

.icon-sales::before {
  left: 2px;
  top: 4px;
  width: 13px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 3px;
  transform: rotate(-20deg);
}

.icon-sales::after {
  left: 5px;
  top: 6px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 7px 5px 0 -1px currentColor;
}

.icon-project::before {
  left: 2px;
  top: 5px;
  width: 14px;
  height: 11px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.icon-project::after {
  left: 4px;
  top: 2px;
  width: 7px;
  height: 5px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
}

.icon-purchase::before,
.icon-inventory::before {
  left: 2px;
  top: 4px;
  width: 14px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 2px;
}

.icon-purchase::after {
  left: 5px;
  top: 1px;
  width: 8px;
  height: 5px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
}

.icon-expense::before {
  left: 2px;
  top: 4px;
  width: 14px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.icon-expense::after {
  left: 4px;
  top: 7px;
  width: 10px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 4px 0 currentColor;
}

.icon-inventory::after {
  left: 2px;
  top: 7px;
  width: 14px;
  height: 2px;
  background: currentColor;
  box-shadow: 5px -3px 0 -1px currentColor;
}

.icon-employee::before {
  left: 6px;
  top: 2px;
  width: 6px;
  height: 6px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-employee::after {
  left: 3px;
  top: 11px;
  width: 12px;
  height: 6px;
  border: 2px solid currentColor;
  border-radius: 999px 999px 0 0;
}

.icon-report::before {
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-report::after {
  left: 8px;
  top: 4px;
  width: 6px;
  height: 7px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.icon-accounting::before {
  left: 3px;
  top: 2px;
  width: 12px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 2px;
}

.icon-accounting::after {
  left: 6px;
  top: 6px;
  width: 8px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 4px 0 currentColor, 0 8px 0 currentColor;
}

.icon-settings::before {
  left: 3px;
  top: 4px;
  width: 14px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
  box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
}

.icon-settings::after {
  left: 5px;
  top: 2px;
  width: 4px;
  height: 4px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: #101828;
  box-shadow: 7px 5px 0 -1px #101828, 7px 5px 0 1px currentColor, 2px 10px 0 -1px #101828, 2px 10px 0 1px currentColor;
}

.subnav {
  display: none;
  gap: 3px;
  padding: 4px 0 8px 34px;
}

.subnav.open {
  display: grid;
}

.subnav button {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 0.86rem;
  font-weight: 800;
}

.subnav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.subnav button.sub-active {
  background: rgba(59, 130, 246, 0.16);
  color: #dbeafe;
  box-shadow: inset 3px 0 0 #60a5fa;
}

.sidebar-collapsed .brand strong,
.sidebar-collapsed .nav-item:not(.active),
.sidebar-collapsed .nav-item.active {
  font-size: 0;
}

.sidebar-collapsed .subnav {
  display: none !important;
}

.sidebar-collapsed .brand,
.sidebar-collapsed .nav-item {
  display: grid;
  justify-content: center;
  place-items: center;
  padding-inline: 0;
}

.sidebar-collapsed .brand {
  width: 48px;
  height: 48px;
  margin-inline: auto;
  padding: 6px;
  border-radius: 14px;
}

.sidebar-collapsed .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.sidebar-collapsed .brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: contain;
  object-position: center;
}

.sidebar-collapsed .nav-list {
  justify-items: center;
  padding: 0;
}

.sidebar-collapsed .nav-item {
  position: relative;
  width: 44px;
  min-height: 44px;
  border-radius: 12px;
  line-height: 0;
}

.sidebar-collapsed .nav-item.active {
  background: rgba(47, 120, 230, 0.18);
  color: #e8f1ff;
  box-shadow: inset 3px 0 0 #4f8df7;
}

.sidebar-collapsed .nav-icon {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  margin: 0;
  transform: translate(-50%, -50%);
}

.main-content {
  min-width: 0;
}

@media (min-width: 901px) {
  .main-content {
    grid-column: 2;
  }
}

.topbar {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 58px;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.user-chip {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #dbe3ee;
  border-radius: 999px;
  background: #f8fafc;
  color: #111827;
  font-weight: 850;
}

.menu-button,
.plain-button,
.primary-outline,
.primary-button,
.secondary-button,
.danger-button,
.link-button,
.icon-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.menu-button {
  width: 44px;
  min-height: 44px;
  margin-right: auto;
  color: #aeb6c3;
  font-size: 1.45rem;
}

.primary-outline {
  padding: 0 16px;
  border: 1px solid var(--blue);
  background: #fff;
  color: var(--blue);
}

.primary-outline:hover,
.secondary-button:hover,
.tab-button:hover {
  border-color: #b8c6d9;
  background: #f8fafc;
}

.primary-button {
  padding: 0 16px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
}

.primary-button:hover {
  background: #1d4ed8;
}

.secondary-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.danger-button {
  padding: 0 14px;
  border: 1px solid #fecaca;
  background: #fff5f5;
  color: #b91c1c;
}

.danger-button:hover {
  border-color: #fca5a5;
  background: #fee2e2;
}

.plain-button {
  padding: 0 14px;
  border-left: 1px solid var(--line);
  border-radius: 0;
}

.plain-button:hover,
.menu-button:hover {
  background: #f8fafc;
}

.doc-menu {
  position: relative;
  margin-right: 14px;
}

.doc-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 290px;
  max-height: min(72vh, 520px);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.doc-dropdown-group {
  display: grid;
  gap: 3px;
  padding: 8px 0;
  border-bottom: 1px solid var(--soft-line);
}

.doc-dropdown-group:first-child {
  padding-top: 0;
}

.doc-dropdown-group:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.doc-dropdown-group strong {
  padding: 2px 10px 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.doc-dropdown button {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
}

.doc-dropdown button:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 4px;
  font-size: 1.42rem;
  line-height: 1.2;
}

.page-head p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.head-actions {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

.table-panel {
  overflow: hidden;
}

.view-root {
  display: grid;
  gap: 14px;
  padding: 16px 28px 28px;
}

.toast {
  margin: 16px 32px 0;
  padding: 12px 16px;
  border: 1px solid #9ad7b0;
  border-radius: 8px;
  background: var(--green-soft);
  color: #146c3a;
  font-weight: 800;
}

.company-overview {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(520px, 1.05fr);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.dashboard-hero {
  grid-template-columns: minmax(320px, 0.82fr) minmax(0, 1.18fr);
  align-items: stretch;
  gap: 14px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.company-card,
.year-summary {
  padding: 18px 22px;
}

.dashboard-hero .company-card,
.dashboard-hero .year-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.company-card {
  border-right: 1px solid var(--line);
}

.dashboard-hero .company-card {
  border-right: 1px solid var(--line);
}

.dashboard-company {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 100%;
  padding: 20px 24px;
}

.dashboard-kicker {
  display: block;
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.company-title-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}

.company-card p {
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 800;
}

.company-card h2 {
  margin-bottom: 10px;
  font-size: 1.35rem;
}

.company-title-row h2 {
  margin: 0;
  font-size: 1.55rem;
}

.company-card dl {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0;
}

.company-card dl.company-meta {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.company-card dl div {
  display: flex;
  gap: 6px;
  min-width: 210px;
}

.company-card dl.company-meta div {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.company-card dt {
  font-weight: 800;
}

.company-card dd {
  margin: 0;
}

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

.summary-toolbar div {
  display: grid;
  gap: 2px;
}

.summary-toolbar strong {
  font-size: 1.02rem;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: 88px;
  border: 1px solid var(--soft-line);
  border-radius: 4px;
  overflow: hidden;
}

.modern-summary {
  gap: 10px;
  min-height: 0;
  border: 0;
  overflow: visible;
}

.summary-strip > div {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 5px;
  padding: 14px 16px;
  border-right: 1px solid var(--soft-line);
  background: #fbfcfe;
}

.modern-summary > div {
  position: relative;
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.modern-summary > div::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cbd5e1;
}

.modern-summary .summary-sales {
  background: #f8fbff;
}

.modern-summary .summary-sales::after {
  background: var(--blue);
}

.modern-summary .summary-cost {
  background: #fffaf2;
}

.modern-summary .summary-cost::after {
  background: var(--orange);
}

.modern-summary .profit {
  background: #f6fff8;
}

.modern-summary .profit::after {
  background: var(--green);
}

.summary-strip > div:last-child {
  border-right: 0;
}

.summary-strip span {
  width: auto;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 800;
}

.summary-strip .profit span {
  background: transparent;
  color: var(--green);
}

.summary-strip strong {
  font-size: 1.45rem;
  line-height: 1.05;
}

.summary-strip small {
  color: var(--muted);
  font-weight: 800;
}

.summary-footnotes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.summary-footnotes span {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.metric-card,
.panel,
.table-panel,
.form-panel {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.metric-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  min-height: 116px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.metric-card.compact {
  min-height: 92px;
  gap: 6px;
  padding: 14px 16px;
}

.metric-card.compact strong {
  font-size: 1.45rem;
}

.metric-card::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cbd5e1;
}

.metric-card span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card strong {
  min-width: 0;
  overflow: hidden;
  font-size: 1.65rem;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card.good {
  border-color: #bfe8cc;
  background: linear-gradient(180deg, #ffffff 0%, var(--green-soft) 100%);
}

.metric-card.good::after {
  background: var(--green);
}

.metric-card.warn {
  border-color: #ffd99a;
  background: linear-gradient(180deg, #ffffff 0%, var(--orange-soft) 100%);
}

.metric-card.warn::after {
  background: var(--orange);
}

.metric-card.bad {
  border-color: #ffc6c6;
  background: linear-gradient(180deg, #ffffff 0%, var(--red-soft) 100%);
}

.metric-card.bad::after {
  background: var(--red);
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.75fr);
  gap: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  border-radius: 4px 4px 0 0;
}

.panel-head h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

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

.quick-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px 12px;
  align-content: start;
  min-height: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.dashboard-layout .quick-card {
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 9px 14px;
  padding: 16px;
  border-radius: 8px;
  background: #fbfcff;
}

.quick-card:hover,
.metric-card:hover,
.panel:hover,
.table-panel:hover {
  box-shadow: var(--shadow);
}

.quick-icon {
  display: grid;
  position: relative;
  grid-row: span 4;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue);
}

.dashboard-layout .quick-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #eaf2ff;
}

.quick-icon::before,
.quick-icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}

.quick-sales::before {
  width: 18px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 4px;
  transform: rotate(-20deg);
}

.quick-sales::after {
  left: 12px;
  top: 14px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 9px 6px 0 -1px currentColor;
}

.quick-purchase::before {
  width: 18px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.quick-purchase::after {
  top: 9px;
  width: 11px;
  height: 7px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.quick-admin::before {
  width: 18px;
  height: 21px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.quick-admin::after {
  width: 12px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 6px 0 currentColor, 0 -6px 0 currentColor;
}

.quick-card h3 {
  margin: 2px 0 4px;
  font-size: 1rem;
}

.dashboard-layout .quick-card h3 {
  align-self: center;
  margin: 0;
  font-size: 1.05rem;
}

.quick-card button,
.status-link {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--blue);
  text-align: left;
  font-weight: 800;
}

.quick-card button:hover,
.status-link:hover,
.doc-link:hover,
.link-button:hover {
  color: #1d4ed8;
}

.quick-card button {
  position: relative;
  padding-left: 14px;
  font-size: 0.92rem;
}

.dashboard-layout .quick-card button {
  grid-column: 2;
  min-height: 28px;
  padding-left: 16px;
  color: #2563eb;
}

.quick-card button::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  transform: translateY(-50%);
}

.status-list,
.activity-list,
.settings-list,
.journal-list {
  display: grid;
}

.status-row,
.activity-row,
.settings-row,
.journal-row {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--soft-line);
}

.status-link {
  width: 100%;
  border-radius: 0;
}

.dashboard-layout .status-list {
  gap: 8px;
  padding: 14px;
}

.dashboard-layout .status-row {
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fff;
}

.dashboard-layout .status-row:last-child {
  border-bottom: 1px solid var(--soft-line);
}

.dashboard-layout .status-row span:first-child {
  color: #344054;
}

.dashboard-layout .status-row span:last-child {
  color: var(--blue);
}

.dashboard-layout .status-row.overdue span:first-child,
.dashboard-layout .status-row.overdue .amount,
.dashboard-layout .status-row.overdue span:last-child {
  color: var(--red);
}

.status-row {
  grid-template-columns: minmax(120px, 1fr) auto auto;
}

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

.dashboard-lower .activity-list {
  padding: 8px 14px;
}

.dashboard-lower .activity-row {
  grid-template-columns: 112px minmax(0, 1fr) auto;
  min-height: 62px;
  padding: 12px 0;
}

.dashboard-lower .activity-row strong {
  line-height: 1.25;
}

.dashboard-lower .activity-row small {
  color: var(--muted);
}

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

.settings-row {
  grid-template-columns: minmax(140px, 0.35fr) minmax(0, 1fr) auto;
}

.status-row:last-child,
.activity-row:last-child,
.settings-row:last-child,
.journal-row:last-child {
  border-bottom: 0;
}

.amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 800;
}

.overdue,
.negative {
  color: var(--red);
}

.paid,
.positive {
  color: var(--green);
}

.toolbar {
  display: grid;
  grid-template-columns: 150px 160px minmax(260px, 1fr) 126px 126px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.toolbar > * {
  border-right: 1px solid var(--line);
}

.toolbar > *:last-child {
  border-right: 0;
}

.search-box {
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  color: #9aa1aa;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
}

.search-box:focus-within {
  background: var(--blue-soft);
}

.table-meta,
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.bulk-bar {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

.bulk-actions {
  display: flex;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #3b414b;
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:nth-child(even) {
  background: #fbfcfe;
}

tbody tr:hover {
  background: #f3f7ff;
}

td.money,
th.money {
  text-align: right;
}

.doc-link {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
}

.doc-link:hover {
  text-decoration: underline;
}

.multiline-text {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.reference-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  font-weight: 800;
  white-space: nowrap;
}

.reference-pill .doc-link {
  font-size: 0.86rem;
}

.muted-cell {
  color: var(--muted);
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf0f4;
  color: #526070;
  font-size: 0.86rem;
  font-weight: 800;
}

.badge.paid,
.badge.active {
  background: var(--green-soft);
  color: var(--green);
}

.badge.pending {
  background: var(--orange-soft);
  color: var(--orange);
}

.badge.warn {
  background: var(--orange-soft);
  color: var(--orange);
}

.badge.overdue {
  background: var(--red-soft);
  color: var(--red);
}

.badge.draft {
  background: #edf0f4;
  color: #626a76;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-weight: 800;
}

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

.chart {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.dashboard-lower .chart {
  gap: 14px;
  padding: 18px 20px 20px;
}

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

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f4;
}

.dashboard-lower .bar-track {
  height: 10px;
  background: #e8eef6;
}

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

.form-panel {
  padding: 18px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.65fr);
  gap: 20px;
}

.settings-page,
.settings-single-view {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.settings-single-view > .panel,
.settings-single-view > .form-panel {
  min-width: 0;
  width: 100%;
}

.settings-single-view .wide-panel,
.settings-single-view .document-style-panel {
  grid-column: auto;
}

.settings-tabs {
  align-items: stretch;
}

.settings-grid > * {
  min-width: 0;
}

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

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

.role-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #fff;
}

.role-card.active {
  border-color: #93c5fd;
  background: var(--blue-soft);
  box-shadow: inset 4px 0 0 var(--blue);
}

.role-card strong {
  color: #111827;
  font-weight: 900;
}

.role-card p,
.role-card small {
  margin: 0;
  color: #64748b;
  font-size: 0.84rem;
  line-height: 1.55;
  font-weight: 700;
}

.user-role-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 16px 0;
}

.user-role-summary > div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #f8fafc;
}

.user-role-summary strong {
  color: #111827;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.user-role-summary span,
.section-title-row p,
.user-cell span,
.user-security small,
.permission-row span,
.settings-note-row span {
  color: #64748b;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.5;
}

.user-role-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 16px;
  padding: 16px;
  align-items: start;
}

.user-role-layout.single {
  grid-template-columns: 1fr;
}

.role-inner-tabs {
  padding: 16px 16px 0;
  border-top: 1px solid #e5e7eb;
}

.user-access-panel,
.role-detail-panel,
.permission-matrix {
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #fff;
  min-width: 0;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid #e5e7eb;
  align-items: flex-start;
}

.section-title-row h3 {
  margin: 0 0 4px;
  color: #111827;
  font-size: 1rem;
  font-weight: 900;
}

.section-title-row p {
  margin: 0;
}

.user-table,
.permission-matrix {
  display: grid;
}

.user-table {
  max-height: min(62vh, 620px);
  overflow: auto;
}

.user-table-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.25fr) minmax(140px, 0.7fr) minmax(180px, 0.95fr) minmax(130px, 0.7fr) minmax(170px, 0.9fr) minmax(92px, 0.45fr);
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  align-items: center;
}

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

.user-table-row.active {
  background: #eff6ff;
  box-shadow: inset 4px 0 0 var(--blue);
}

.user-table-head,
.permission-head {
  background: #f8fafc;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 900;
}

.user-table-head {
  position: sticky;
  top: 0;
  z-index: 1;
}

.user-table-row label {
  display: grid;
  gap: 6px;
  margin: 0;
}

.user-table-row label > span {
  display: none;
}

.user-table-row select,
.user-table-row input {
  width: 100%;
  min-width: 0;
}

.user-cell,
.user-security,
.user-edit-fields,
.user-actions {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.user-cell strong {
  color: #111827;
  font-weight: 900;
}

.user-security {
  justify-items: start;
}

.user-security input {
  margin-top: 2px;
}

.user-edit-fields {
  gap: 8px;
}

.user-actions {
  justify-items: start;
}

.user-actions small {
  color: #64748b;
  font-size: 0.74rem;
}

.user-actions .secondary-button {
  min-height: 34px;
  padding: 0 12px;
}

.role-grid.compact {
  grid-template-columns: 1fr;
  padding: 14px;
}

.permission-matrix {
  margin: 0 16px 16px;
  overflow: hidden;
}

.user-role-layout.single .permission-matrix {
  margin: 0;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) repeat(4, minmax(90px, 0.65fr));
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  align-items: center;
}

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

.permission-row.active {
  background: #eff6ff;
}

.permission-row strong {
  display: block;
  color: #111827;
  font-weight: 900;
}

.permission-row > div span {
  display: block;
  margin-top: 3px;
}

.settings-note-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 16px;
  align-items: center;
}

.settings-note-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

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

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

.settings-table {
  display: grid;
  gap: 0;
  padding: 6px 14px 14px;
}

.settings-table-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 86px 118px 112px;
  gap: 12px;
  align-items: center;
  min-height: 56px;
  padding: 9px 0;
  border-bottom: 1px solid var(--soft-line);
}

.settings-table-head {
  min-height: 34px;
  padding: 4px 0 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

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

.settings-table-row strong {
  font-size: 0.95rem;
  line-height: 1.35;
}

.settings-table-row label {
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.settings-table-row label > span {
  display: none;
}

.settings-table-row input {
  min-height: 34px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 0.92rem;
}

.settings-table-row code {
  align-self: center;
  justify-self: end;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #f8fafc;
  color: #344054;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

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

label {
  display: grid;
  gap: 6px;
  color: #333944;
  font-weight: 800;
}

input,
select,
textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input[readonly] {
  background: #f8fafc;
  color: #697386;
  cursor: not-allowed;
}

select:disabled {
  background: #f8fafc;
  color: #697386;
  cursor: not-allowed;
  opacity: 1;
}

input[readonly]:focus {
  border-color: var(--line);
  box-shadow: none;
}

textarea {
  padding-top: 10px;
  resize: vertical;
}

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

dialog {
  width: min(720px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(26, 32, 44, 0.48);
}

.document-dialog {
  width: min(1120px, calc(100% - 28px));
  max-height: min(92vh, 980px);
  overflow: auto;
}

.project-dialog {
  width: min(1180px, calc(100% - 32px));
  max-height: 90vh;
  overflow: hidden;
}

.project-dialog .dialog-card {
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: 90vh;
  padding: 0;
  gap: 0;
}

.project-dialog .dialog-head {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--soft-line);
  background: #fff;
}

.project-dialog .document-form-layout {
  overflow-y: auto;
  padding: 18px 24px 22px;
}

.project-dialog .dialog-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--soft-line);
  background: #fff;
}

.project-dialog .dialog-head .icon-button {
  width: 42px;
  min-height: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #dbe3ee;
  background: #f8fafc;
  color: #111827;
  line-height: 1;
}

.project-dialog input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: var(--blue);
}

.project-dialog .toggle-field {
  min-height: 48px;
  align-content: center;
  padding: 11px 12px;
  border: 1px solid #d7dbe2;
  border-radius: 8px;
  background: #f8fafc;
}

.project-dialog .toggle-field > span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
}

.project-form-section {
  padding: 0;
}

.project-form-section > .document-section-head {
  cursor: pointer;
  padding: 14px 16px;
  list-style: none;
}

.project-form-section > .document-section-head::-webkit-details-marker {
  display: none;
}

.project-form-section > .document-section-head::before {
  content: "▾";
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.project-form-section:not([open]) > .document-section-head {
  border-bottom: 0;
}

.project-form-section:not([open]) > .document-section-head::before {
  transform: rotate(-90deg);
}

.project-form-section > .form-grid,
.project-form-section > .project-service-list {
  padding: 0 16px 16px;
}

.customer-form-mode [data-form-section="document"],
.customer-form-mode [data-form-section="items"],
.customer-form-mode [data-form-section="summary"] {
  display: none;
}

#detailDialog {
  width: min(1120px, calc(100% - 28px));
  max-height: min(92vh, 980px);
  overflow: auto;
}

.dialog-card {
  display: grid;
  gap: 16px;
  padding: 24px;
}

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

.dialog-head p {
  margin-bottom: 0;
  color: var(--blue);
  font-weight: 800;
  text-transform: uppercase;
}

.popup-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  color: #64748b !important;
  font-size: 0.82rem;
  text-transform: none !important;
}

.popup-breadcrumb span {
  font-weight: 850;
}

.popup-breadcrumb span:first-child,
.popup-breadcrumb .breadcrumb-link:first-child {
  color: var(--blue);
}

.popup-breadcrumb b {
  color: #cbd5e1;
  font-weight: 800;
}

.breadcrumb-link {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  letter-spacing: 0;
}

.breadcrumb-link:hover {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dialog-head h2 {
  margin-bottom: 0;
}

.icon-button {
  width: 40px;
  background: #eef1f5;
  font-size: 1.3rem;
}

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

.customer-search-field {
  position: relative;
}

.customer-suggestions {
  display: grid;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  z-index: 30;
  overflow: hidden;
  border: 1px solid #cbd8ee;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16);
}

.customer-suggestion {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  min-height: 58px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--soft-line);
  border-radius: 0;
  background: #fff;
  text-align: left;
}

.customer-suggestion:last-child {
  border-bottom: 0;
}

.customer-suggestion:hover,
.customer-suggestion:focus-visible {
  background: #f4f8ff;
  transform: none;
}

.customer-suggestion strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-suggestion span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.customer-suggestion small {
  align-self: start;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
}

.customer-suggestion-empty {
  padding: 12px;
  color: var(--muted);
  font-weight: 800;
}

.document-form-layout {
  display: grid;
  gap: 14px;
}

.document-section {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

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

.document-section-head strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.document-section-head span {
  color: var(--muted);
  font-weight: 800;
}

.document-section-head .link-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid #b7ccff;
  border-radius: 4px;
  background: #f3f7ff;
  color: var(--blue);
  box-shadow: 0 1px 0 rgba(47, 120, 230, 0.08);
  white-space: nowrap;
}

.document-section-head .link-button::before {
  content: "+";
  display: inline-grid;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 0.82rem;
  line-height: 1;
}

.document-section-head .link-button[data-edit-doc]::before {
  content: "";
  background:
    linear-gradient(#fff, #fff) 6px 11px / 8px 2px no-repeat,
    linear-gradient(135deg, transparent 0 39%, #fff 40% 60%, transparent 61%) center / 12px 12px no-repeat,
    var(--blue);
}

.document-section-head .link-button[data-section-target]::before {
  content: "›";
  font-size: 1rem;
}

.document-section-head .link-button[data-toast*="แนบ"]::before {
  content: "↥";
  font-size: 0.86rem;
}

.document-section-head .link-button:hover {
  border-color: var(--blue);
  background: #eaf1ff;
  color: #174ea6;
}

.line-item-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow-x: auto;
}

.line-item-head,
.line-item-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(260px, 1.1fr) 100px 140px 120px 140px 56px;
  min-width: 1040px;
  align-items: center;
}

.line-item-head {
  min-height: 44px;
  align-items: center;
  background: #f8fafc;
  color: #3b414b;
  font-weight: 800;
}

.line-item-row {
  align-items: stretch;
}

.line-item-head span,
.line-item-row input,
.line-item-row textarea,
.line-item-row strong,
.line-item-row .remove-line-item {
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.line-item-head span:last-child,
.line-item-row .remove-line-item:last-child {
  border-right: 0;
}

.line-item-row input,
.line-item-row textarea {
  min-height: 48px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.line-item-row textarea {
  min-height: 70px;
  resize: vertical;
  line-height: 1.5;
}

.line-item-row strong {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.line-item-row .remove-line-item {
  width: 100%;
  min-height: 70px;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  font-size: 1rem;
}

.line-item-row .remove-line-item:hover {
  background: var(--red-soft);
  color: var(--red);
}

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

.project-service-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

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

.project-service-head strong {
  display: grid;
  gap: 2px;
  color: #111827;
  font-weight: 900;
}

.project-service-head strong span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.project-service-card .form-grid {
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.project-service-card label span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #374151;
}

.project-link-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

.project-summary-grid .metric-card {
  min-height: 88px;
  gap: 6px;
  padding: 12px 14px;
}

.project-summary-grid .metric-card::after {
  right: 12px;
  top: 12px;
  width: 8px;
  height: 8px;
}

.project-summary-grid .metric-card strong {
  font-size: clamp(1.05rem, 1.25vw, 1.38rem);
  letter-spacing: 0;
}

.project-summary-grid .metric-card span,
.project-summary-grid .metric-card small {
  padding-right: 10px;
  font-size: 0.76rem;
}

.project-filter-bar {
  grid-template-columns: minmax(260px, 1.4fr) repeat(3, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.project-filter-bar > * {
  border-right: 0;
}

.project-filter-bar label:not(.search-box) {
  display: grid;
  gap: 6px;
}

.project-filter-bar label > span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.project-filter-bar select,
.project-filter-bar .plain-button {
  min-height: 42px;
}

.project-search-field {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.project-table {
  width: 100%;
  min-width: 1120px;
  table-layout: fixed;
}

.project-table th,
.project-table td {
  white-space: normal;
  word-break: break-word;
}

.project-table th:nth-child(1),
.project-table td:nth-child(1) {
  width: 42px;
}

.project-table th:nth-child(2),
.project-table td:nth-child(2) {
  width: 168px;
}

.project-table th:nth-child(3),
.project-table td:nth-child(3) {
  width: 260px;
}

.project-table th:nth-child(4),
.project-table td:nth-child(4) {
  width: 210px;
}

.project-table th:nth-child(5),
.project-table td:nth-child(5) {
  width: 220px;
}

.project-table th:nth-child(6),
.project-table td:nth-child(6) {
  width: 120px;
}

.project-table th:nth-child(7),
.project-table td:nth-child(7) {
  width: 170px;
}

.project-table th:nth-child(8),
.project-table td:nth-child(8) {
  width: 150px;
}

.project-table th:nth-child(9),
.project-table td:nth-child(9) {
  width: 150px;
}

.project-table th:nth-child(1),
.project-table td:nth-child(1),
.project-table th:nth-child(2),
.project-table td:nth-child(2),
.project-table th:nth-child(3),
.project-table td:nth-child(3) {
  position: sticky;
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 var(--soft-line);
}

.project-table th:nth-child(1),
.project-table td:nth-child(1) {
  left: 0;
}

.project-table th:nth-child(2),
.project-table td:nth-child(2) {
  left: 42px;
}

.project-table th:nth-child(3),
.project-table td:nth-child(3) {
  left: 210px;
}

.project-table th:nth-child(1),
.project-table th:nth-child(2),
.project-table th:nth-child(3) {
  z-index: 4;
  background: #f8fafc;
}

.project-table tbody tr:nth-child(even) td:nth-child(1),
.project-table tbody tr:nth-child(even) td:nth-child(2),
.project-table tbody tr:nth-child(even) td:nth-child(3) {
  background: #fbfcfe;
}

.project-table tbody tr:hover td:nth-child(1),
.project-table tbody tr:hover td:nth-child(2),
.project-table tbody tr:hover td:nth-child(3) {
  background: #f3f7ff;
}

.project-action-cell .secondary-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.project-action-cell .project-link-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.project-action-cell .project-link-stack button:last-child {
  grid-column: 1 / -1;
}

.project-list-cards {
  display: none;
}

.project-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--soft-line);
  background: #fff;
}

.project-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.project-card h3 {
  display: -webkit-box;
  overflow: hidden;
  margin: 3px 0 1px;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.22;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.project-card p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
}

.project-card-meta div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 8px;
  min-width: 0;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #f8fafc;
}

.project-card-meta dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.project-card-meta dd {
  overflow: hidden;
  margin: 0;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card-meta small {
  margin-left: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.project-card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.project-card-actions button {
  min-height: 36px;
  padding: 0 6px;
  font-size: 0.76rem;
}

.project-mini-list {
  display: grid;
  gap: 8px;
}

.project-mini-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #fff;
}

.project-mini-row small {
  color: var(--muted);
  font-weight: 750;
}

@media (max-height: 760px) {
  .project-dialog,
  .project-dialog .dialog-card {
    max-height: 96vh;
  }

  .project-dialog .dialog-head {
    padding: 14px 20px 12px;
  }

  .project-dialog .document-form-layout {
    padding: 14px 20px 18px;
  }
}

@media (max-width: 760px) {
  .project-dialog {
    width: calc(100% - 12px);
    max-height: 96vh;
  }

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

.detail-item-row small {
  display: block;
  margin-top: 4px;
  color: #6b7280;
  font-weight: 700;
  line-height: 1.45;
}

.document-summary-section {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  align-items: start;
}

.document-totals {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.document-totals div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px;
  border-bottom: 1px solid var(--soft-line);
}

.document-totals div:last-child {
  border-bottom: 0;
}

.document-totals span {
  color: var(--muted);
  font-weight: 800;
}

.document-totals strong {
  font-variant-numeric: tabular-nums;
}

.document-totals .grand-total {
  min-height: 56px;
  background: var(--blue-soft);
  color: var(--blue);
}

.document-totals .grand-total span,
.document-totals .grand-total strong {
  color: var(--blue);
  font-size: 1.08rem;
}

.attachment-drop {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: #fbfcfe;
  color: var(--blue);
  font-weight: 800;
}

.attachment-drop input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.document-detail {
  display: grid;
  gap: 14px;
}

.detail-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfe;
}

.detail-hero h3 {
  margin: 8px 0 2px;
  font-size: 1.35rem;
}

.detail-hero p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.detail-actions-bottom {
  justify-content: flex-start;
}

.document-actions-section {
  background: #fbfcfe;
}

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

.detail-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--soft-line);
}

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

.detail-list dt {
  color: var(--muted);
  font-weight: 800;
}

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

.detail-items {
  --detail-item-columns: minmax(420px, 1.45fr) minmax(80px, 0.32fr) minmax(120px, 0.42fr) minmax(110px, 0.38fr) minmax(130px, 0.45fr);
  display: grid;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.detail-item-head,
.detail-item-row {
  display: grid;
  grid-template-columns: var(--detail-item-columns);
  min-width: 860px;
  align-items: center;
}

.detail-item-head {
  min-height: 44px;
  background: #f8fafc;
  color: #3b414b;
  font-weight: 800;
}

.detail-item-head span,
.detail-item-row span,
.detail-item-row strong {
  padding: 12px;
  border-right: 1px solid var(--line);
}

.detail-item-head span:not(:first-child),
.detail-item-row > span:not(:first-child),
.detail-item-row > strong:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.detail-item-row > span:first-child strong {
  display: block;
  padding: 0;
  border-top: 0;
  border-right: 0;
  text-align: left;
  font-variant-numeric: normal;
}

.detail-item-row span,
.detail-item-row strong {
  border-top: 1px solid var(--line);
}

.detail-item-row > span:first-child strong {
  border-top: 0;
}

.detail-item-head span:last-child,
.detail-item-row strong:last-child {
  border-right: 0;
}

.timeline {
  display: grid;
  gap: 0;
}

.timeline div {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--soft-line);
}

.timeline div:last-child {
  border-bottom: 0;
}

.timeline span {
  color: var(--muted);
  font-weight: 800;
}

.sales-detail-flow {
  background: #fbfcfe;
}

.detail-flow-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.detail-flow-step {
  display: grid;
  min-height: 84px;
  align-content: start;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.detail-flow-step span {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #e8eef8;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

.detail-flow-step strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.detail-flow-step small {
  color: var(--muted);
  font-weight: 800;
}

.detail-flow-step.done {
  border-color: #bfe8cc;
  background: var(--green-soft);
}

.detail-flow-step.active {
  border-color: #8bb5ff;
  background: #f3f7ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.detail-flow-step.active span {
  background: var(--blue);
  color: #fff;
}

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

.flow-reference-grid > div {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: 4px;
  background: #fff;
}

.flow-reference-grid span {
  color: var(--muted);
  font-weight: 800;
}

.flow-reference-grid strong {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--ink);
}

.print-dialog {
  width: min(1180px, calc(100% - 24px));
  height: min(92vh, 980px);
  max-height: min(92vh, 980px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f4f7fb;
}

.print-shell {
  display: block;
  height: 100%;
  min-height: 0;
}

.print-side-tools {
  display: none;
  align-content: start;
  gap: 10px;
  padding: 18px 8px;
  background: var(--nav);
}

.print-tool {
  min-height: 54px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #e7edf7;
  font-size: 1.35rem;
  font-weight: 900;
}

.print-tool.active,
.print-tool:hover {
  background: rgba(255, 255, 255, 0.12);
}

.print-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  height: 100%;
  min-height: 0;
}

.print-tabs {
  display: none;
  align-items: end;
  gap: 0;
  padding: 10px 20px 0;
  background: #202842;
  overflow: hidden;
}

.print-tab {
  min-width: 220px;
  max-width: 320px;
  min-height: 48px;
  padding: 0 28px;
  border: 0;
  border-radius: 14px 28px 0 0;
  background: #f8fafc;
  color: #1b2744;
  font-weight: 900;
  text-align: left;
  transform: skewX(22deg);
  transform-origin: bottom left;
}

.print-tab::first-letter {
  color: var(--accent);
}

.print-tab > * {
  display: inline-block;
  transform: skewX(-22deg);
}

.print-tab.muted {
  margin-left: -10px;
  background: #eef1f6;
  color: #64748b;
}

.print-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 76px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.print-toolbar p {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.print-toolbar .popup-breadcrumb {
  margin: 0 0 3px;
  letter-spacing: 0;
  text-transform: none;
}

.print-toolbar strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.print-options {
  display: flex;
  align-items: center;
  gap: 12px;
}

.print-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}

.print-area {
  overflow: auto;
  min-height: 0;
  padding: 24px;
  overscroll-behavior: contain;
}

.print-page {
  width: 880px;
  max-width: 100%;
  min-height: 1245px;
  margin: 0 auto;
  padding: 54px 58px 46px;
  background: #fff;
  color: #222;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.2);
  font-size: 0.82rem;
}

.print-doc-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 28px;
  padding-bottom: 28px;
  border-bottom: 2px solid #e5e7eb;
}

.print-brand {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.print-logo-text {
  min-width: 190px;
  padding-top: 18px;
  color: #0f1c2f;
  font-size: 2.45rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
}

.print-brand h2,
.print-doc-title h1 {
  font-size: 1.55rem;
  line-height: 1.15;
}

.print-doc-title span {
  font-size: 0.82rem;
}

.print-info-grid h3,
.print-note h3 {
  font-size: 0.9rem;
}

.print-info-grid dl div {
  grid-template-columns: 95px minmax(0, 1fr);
}

.print-signatures strong,
.print-signatures small {
  font-size: 0.78rem;
}

@media screen and (max-width: 760px) {
  .print-page {
    width: 820px;
    padding: 44px 42px;
  }
}

@media (max-width: 720px) {
  .login-screen {
    padding: 14px;
  }

  .login-panel {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 20px;
    border-radius: 14px;
  }

  .login-copy h1 {
    font-size: 1.85rem;
  }

  .login-roles {
    grid-template-columns: 1fr;
  }
}

@media print {
  .print-page {
    padding: 16mm 14mm 14mm !important;
    font-size: 8.6pt !important;
  }

  .print-doc-head {
    grid-template-columns: minmax(0, 1fr) 46mm !important;
    gap: 8mm !important;
    padding-bottom: 9mm !important;
  }

  .print-logo-text {
    min-width: 34mm !important;
    font-size: 21pt !important;
  }

  .print-doc-title h1 {
    font-size: 14pt !important;
  }

  .print-doc-title strong {
    font-size: 11pt !important;
  }

  .print-info-grid,
  .print-bottom-grid {
    grid-template-columns: minmax(0, 1fr) 54mm !important;
    gap: 10mm !important;
    margin-top: 10mm !important;
  }

  .print-items {
    margin-top: 14mm !important;
    font-size: 7.8pt !important;
  }

  .print-signatures {
    margin-top: 13mm !important;
  }
}

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

  .project-summary-grid .metric-card {
    min-height: 72px;
  }

  .project-secondary-card {
    display: none;
  }

  .project-filter-bar.toolbar {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
  }

  .project-table-wrap {
    display: none;
  }

  .project-list-cards {
    display: grid;
  }

  .project-panel .table-meta {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.82rem;
  }
}

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

  .project-summary-grid .metric-card {
    min-height: 64px;
    padding: 9px 10px;
  }

  .project-summary-grid .metric-card strong {
    font-size: 1.1rem;
  }

  .project-summary-grid .metric-card small {
    display: none;
  }

  .project-filter-bar.toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-filter-bar label:nth-of-type(2),
  .project-filter-bar label:nth-of-type(4),
  .project-filter-bar label:nth-of-type(5),
  .project-filter-bar label:nth-of-type(6) {
    display: none;
  }

  .project-search-field,
  .project-filter-bar .plain-button {
    grid-column: 1 / -1;
  }

  .project-filter-bar select,
  .project-filter-bar .plain-button,
  .project-search-field {
    min-height: 38px;
  }

  .project-filter-bar label > span {
    display: none;
  }

  .project-panel .table-meta {
    display: none;
  }

  .project-panel .tabs {
    padding: 8px 8px 6px;
  }

  .project-panel .tab-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  .project-card {
    gap: 8px;
    padding: 10px;
  }

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

  .project-card-secondary {
    display: none !important;
  }

  .project-card-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .project-card-actions button {
    min-height: 34px;
    font-size: 0.74rem;
  }
}

@media (max-width: 1120px) {
  .project-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .project-filter-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .project-search-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1280px) {
  .project-table-wrap {
    display: none;
  }

  .project-list-cards {
    display: grid;
  }

  .project-panel .table-meta {
    min-height: 40px;
    padding: 8px 12px;
  }
}

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

  .project-filter-bar {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
  }

  .project-table-wrap {
    display: none;
  }

  .project-list-cards {
    display: grid;
  }

  .project-secondary-card {
    display: none;
  }
}

@media (max-width: 760px) {
  .project-dialog {
    width: calc(100% - 12px);
    max-height: 96vh;
  }

  .project-dialog .dialog-card {
    max-height: 96vh;
  }

  .project-dialog .dialog-head {
    padding: 12px 14px;
  }

  .project-dialog .document-form-layout {
    gap: 8px;
    padding: 8px 8px 10px;
  }

  .project-dialog .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 10px;
  }

  .project-form-section > .document-section-head {
    min-height: 44px;
    padding: 10px 12px;
  }

  .project-form-section > .form-grid,
  .project-form-section > .project-service-list {
    padding: 0 10px 10px;
  }

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

  .project-card-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .project-summary-grid .metric-card {
    min-height: 64px;
    padding: 9px 10px;
  }

  .project-summary-grid .metric-card strong {
    font-size: 1.1rem;
  }

  .project-summary-grid .metric-card small {
    display: none;
  }

  .project-filter-bar label:not(.search-box) {
    gap: 4px;
  }

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

  .project-search-field,
  .project-filter-bar .plain-button {
    grid-column: 1 / -1;
  }

  .project-filter-bar select,
  .project-filter-bar .plain-button,
  .project-search-field {
    min-height: 38px;
  }

  .project-card {
    gap: 8px;
    padding: 10px;
  }

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

  .project-card-secondary {
    display: none !important;
  }

  .project-card-actions button {
    min-height: 34px;
    font-size: 0.74rem;
  }
}

.print-doc-title h1 {
  margin: 0 0 8px;
}

.print-brand h2 {
  font-size: 1rem;
}

.print-brand p,
.print-info-grid p,
.print-note p {
  margin: 0 0 4px;
  color: #4b5563;
  font-weight: 700;
}

.print-doc-title {
  padding: 8px 0 8px 22px;
  border-left: 2px solid #e5e7eb;
}

.print-doc-title span {
  color: #6b7280;
  font-weight: 800;
}

.print-doc-title strong {
  display: block;
  font-size: 1.05rem;
}

.print-info-grid,
.print-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 34px;
  margin-top: 32px;
}

.print-info-grid h3,
.print-note h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.print-info-grid h4 {
  margin: 0 0 8px;
  color: #2c2f36;
  font-size: 1rem;
}

.print-info-grid dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.print-info-grid dl div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
}

.print-info-grid dt {
  color: #6b7280;
  font-weight: 800;
}

.print-info-grid dd {
  margin: 0;
  font-weight: 800;
}

.print-items {
  width: 100%;
  min-width: 0;
  margin-top: 48px;
  border-collapse: collapse;
}

.print-items th {
  position: static;
  background: #17213a;
  color: #fff;
  font-size: 0.82rem;
  text-align: left;
}

.print-items th,
.print-items td {
  padding: 9px 10px;
  border: 1px solid #d4dae5;
  white-space: normal;
  vertical-align: top;
}

.print-items td:nth-child(1),
.print-items td:nth-child(3),
.print-items th:nth-child(1),
.print-items th:nth-child(3) {
  text-align: center;
}

.print-items small {
  display: block;
  margin-top: 4px;
  color: #4b5563;
  font-weight: 700;
}

.print-items td:last-child,
.print-items th:last-child,
.print-total-box strong {
  text-align: right;
}

.print-total-box {
  border: 1px solid #d7dce5;
  font-weight: 800;
}

.print-total-box div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid #e5e7eb;
}

.print-total-box div:last-child {
  border-bottom: 0;
}

.print-grand {
  background: #17213a;
  color: #fff;
}

.print-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 34px;
  margin-top: 64px;
}

.print-signatures div {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.print-signatures span {
  width: 100%;
  height: 42px;
  border-bottom: 1px solid #9ca3af;
}

.print-signatures small {
  color: #6b7280;
  font-weight: 700;
}

.print-bottom-grid {
  align-items: start;
  margin-top: 28px;
}

.print-note {
  min-height: 86px;
}

.print-note p {
  line-height: 1.7;
}

.print-page {
  display: flex;
  flex-direction: column;
}

.print-signatures {
  margin-top: auto;
  padding-top: 34px;
}

@media (max-width: 760px) {
  .print-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
  }

  .print-shell {
    display: block;
  }

  .print-toolbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 14px;
  }

  .print-options {
    flex-wrap: wrap;
  }

  .print-area {
    padding: 14px;
  }

  .print-page {
    width: 900px;
    max-width: none;
    padding: 46px 42px;
  }
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 42px 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

@media (max-width: 1120px) {
  .summary-grid,
  .quick-grid,
  .role-grid,
  .user-role-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .work-grid,
  .settings-grid,
  .user-role-layout,
  .company-overview {
    grid-template-columns: 1fr;
  }

  .company-card {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 900px) {
  body.mobile-nav-open {
    overflow: hidden;
  }

  .app-shell,
  .app-shell.sidebar-collapsed {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(82vw, 280px);
    height: 100dvh;
    padding: 14px 12px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 18px 0 42px rgba(15, 23, 42, 0.32);
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    border: 0;
    background: rgba(15, 23, 42, 0.48);
  }

  .brand {
    justify-content: center;
    width: 100%;
    height: 64px;
    margin-inline: 0;
    padding: 6px 10px;
  }

  .brand-logo-full {
    width: 228px;
    max-width: 100%;
    height: 58px;
  }

  .nav-list {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: stretch;
    padding: 0;
    gap: 4px;
  }

  .nav-item {
    display: flex;
    position: static;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: flex-start;
    padding: 0 14px;
    border-radius: 12px;
    box-shadow: none !important;
    font-size: 0.92rem;
    line-height: 1.2;
  }

  .nav-item.active {
    background: rgba(47, 120, 230, 0.18);
    color: #e8f1ff;
    box-shadow: inset 3px 0 0 #4f8df7 !important;
  }

  .nav-icon {
    display: inline-block;
    position: static;
    width: 16px;
    height: 16px;
    margin-right: 12px;
    transform: none;
  }

  .subnav {
    display: none !important;
  }

  .subnav.open {
    display: grid !important;
  }

  .subnav button {
    justify-content: flex-start;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    background: transparent;
    text-align: left;
    font-size: 0.86rem;
  }

  .topbar {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    min-height: auto;
    align-items: center;
    gap: 8px;
    padding: 8px;
  }

  .user-menu {
    grid-column: 1 / -1;
    justify-content: flex-end;
    margin-left: 0;
  }

  .menu-button {
    width: 44px;
    min-height: 44px;
    margin: 0;
    border-radius: 8px;
    font-size: 1.4rem;
  }

  .doc-menu {
    min-width: 0;
  }

  .primary-outline {
    width: 100%;
    min-height: 44px;
    padding: 0 10px;
  }

  .plain-button {
    min-height: 44px;
    padding: 0 10px;
    border-left: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
    padding: 18px 16px;
  }

  h1 {
    font-size: 1.45rem;
  }

  .head-actions,
  .summary-grid,
  .quick-grid,
  .role-grid,
  .user-role-summary,
  .toolbar,
  .field-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .user-table-row,
  .permission-row {
    grid-template-columns: 1fr;
  }

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

  .user-table-row > .user-cell,
  .user-table-row > .user-security,
  .user-table-row > .user-edit-fields,
  .user-table-row > .user-actions {
    grid-column: 1 / -1;
  }

  .user-security,
  .user-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .user-security input {
    max-width: 260px;
  }

  .user-table-head,
  .permission-head {
    display: none;
  }

  .user-table {
    max-height: 58vh;
  }

  .user-table-row label > span {
    display: block;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 900;
  }

  .settings-note-row,
  .section-title-row {
    display: grid;
  }

  .summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: 78px;
  }

  .settings-table-row {
    grid-template-columns: minmax(0, 1fr) 82px 112px;
  }

  .settings-table-head {
    display: none;
  }

  .settings-table-row code {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .summary-strip > div {
    padding: 12px;
  }

  .head-actions {
    display: grid;
  }

  .view-root {
    padding: 16px;
  }

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

  .detail-flow-rail,
  .flow-reference-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    border-bottom: 0;
    gap: 8px;
    padding: 12px;
  }

  .toolbar > * {
    border-right: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 10px;
  }

  .tab-button {
    flex: 0 0 auto;
  }

  .table-wrap {
    position: relative;
    border-top: 1px solid var(--line);
  }

  .table-wrap::before {
    content: "เลื่อนซ้าย-ขวาเพื่อดูตารางทั้งหมด";
    display: block;
    position: sticky;
    left: 0;
    z-index: 2;
    padding: 8px 12px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    border-bottom: 1px solid var(--soft-line);
  }

  table {
    min-width: 1120px;
  }

  dialog {
    width: min(100% - 20px, 720px);
  }

  .dialog-card {
    padding: 18px;
  }

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

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

  .detail-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .detail-list div,
  .timeline div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .document-section {
    padding: 14px;
  }

  .document-section-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

@media (max-width: 560px) {
  .summary-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }

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

  .summary-strip > div {
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
  }

  .summary-strip > div:last-child {
    border-bottom: 0;
  }

  .status-row,
  .activity-row,
  .settings-row,
  .journal-row {
    grid-template-columns: 1fr;
  }

  .settings-table-row {
    grid-template-columns: 1fr;
  }

  .settings-table-row label > span {
    display: block;
  }

  .settings-table-row code {
    justify-self: stretch;
    text-align: center;
  }
}

/* Dialog UX refinements */
html,
body {
  overflow-x: hidden;
}

#documentDialog,
#detailDialog {
  overflow: hidden;
}

#documentDialog .dialog-card,
#detailDialog .dialog-card {
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(92vh, 980px);
  padding: 0;
  gap: 0;
}

#documentDialog .dialog-head,
#detailDialog .dialog-head {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--soft-line);
  background: #fff;
}

#documentDialog .document-form-layout,
#detailDialog #detailContent {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 24px 22px;
}

#documentDialog .dialog-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--soft-line);
  background: #fff;
  box-shadow: 0 -12px 28px rgba(15, 23, 42, 0.08);
}

.document-form-section {
  padding: 0;
}

.document-form-section > .document-section-head {
  cursor: pointer;
  padding: 14px 16px;
  list-style: none;
}

.document-form-section > .document-section-head::-webkit-details-marker {
  display: none;
}

.document-form-section > .document-section-head::before {
  content: "▾";
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.document-form-section:not([open]) > .document-section-head {
  border-bottom: 0;
}

.document-form-section:not([open]) > .document-section-head::before {
  transform: rotate(-90deg);
}

.document-form-section > .form-grid,
.document-form-section > .line-item-table,
.document-form-section > .document-totals,
.document-form-section > .attachment-drop {
  margin: 0 16px 16px;
}

.document-summary-section > .form-grid {
  margin-bottom: 12px;
}

.detail-items {
  overflow-x: hidden;
}

.print-dialog {
  width: min(1180px, calc(100% - 28px));
  max-height: 94vh;
  overflow: hidden;
}

.print-shell,
.print-workspace {
  max-height: 94vh;
  min-height: 0;
}

.print-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.print-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
}

.print-area {
  min-height: 0;
  overflow: auto;
}

@media (max-width: 760px) {
  .topbar {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px 12px;
  }

  .doc-menu {
    grid-column: 2 / 3;
    position: static;
    width: auto;
    min-width: 0;
    margin: 0;
  }

  .doc-dropdown {
    position: fixed;
    inset: auto 10px 10px;
    z-index: 80;
    width: auto;
    max-height: min(74vh, 620px);
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  }

  .doc-dropdown-group {
    gap: 6px;
    padding: 12px 0;
  }

  .doc-dropdown-group button {
    min-height: 44px;
  }

  #documentDialog,
  #detailDialog,
  #printDialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }

  #documentDialog .dialog-card,
  #detailDialog .dialog-card {
    max-height: calc(100dvh - 16px);
  }

  #documentDialog .dialog-head,
  #detailDialog .dialog-head {
    padding: 14px 14px 12px;
  }

  #documentDialog .dialog-head h2,
  #detailDialog .dialog-head h2 {
    font-size: 1.08rem;
    line-height: 1.35;
  }

  #documentDialog .document-form-layout,
  #detailDialog #detailContent {
    padding: 12px;
    overflow-x: hidden;
  }

  #documentDialog .dialog-actions {
    grid-template-columns: 1fr;
    display: grid;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }

  #documentDialog .dialog-actions button {
    width: 100%;
    min-height: 44px;
  }

  .document-form-section > .document-section-head {
    align-items: center;
    flex-direction: row;
    padding: 12px;
  }

  .document-form-section > .document-section-head strong {
    min-width: 0;
  }

  .document-form-section > .document-section-head span {
    text-align: right;
  }

  .document-form-section > .form-grid,
  .document-form-section > .line-item-table,
  .document-form-section > .document-totals,
  .document-form-section > .attachment-drop {
    margin: 0 12px 12px;
  }

  .line-item-table {
    overflow: visible;
    border: 0;
    gap: 10px;
  }

  .line-item-head {
    display: none;
  }

  #lineItems {
    display: grid;
    gap: 10px;
  }

  .line-item-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
  }

  .line-item-row input,
  .line-item-row textarea,
  .line-item-row strong,
  .line-item-row .remove-line-item {
    min-width: 0;
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
  }

  .line-item-row textarea,
  .line-item-row .document-item-name {
    grid-column: 1 / -1;
  }

  .line-item-row strong {
    justify-content: flex-start;
    color: var(--blue);
  }

  .line-item-row .remove-line-item {
    width: 100%;
    color: var(--red);
    font-size: 1.15rem;
  }

  .detail-item-head {
    display: none;
  }

  .detail-item-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
    margin-bottom: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
  }

  .detail-item-row > span:first-child,
  .detail-item-row > strong {
    grid-column: 1 / -1;
  }

  .detail-item-row > strong {
    color: var(--blue);
    text-align: left;
  }

  .print-shell,
  .print-workspace {
    max-height: calc(100dvh - 16px);
  }

  .print-toolbar {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

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

  .print-options label {
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
  }

  .print-options button {
    min-height: 42px;
  }

  .print-area {
    padding: 12px;
  }

  .print-page {
    width: 210mm;
    min-width: 210mm;
    transform-origin: top left;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html,
  body {
    background: #fff;
    margin: 0 !important;
    padding: 0 !important;
  }

  .app-shell,
  #documentDialog,
  #detailDialog,
  .print-side-tools,
  .print-toolbar {
    display: none !important;
  }

  #printDialog {
    display: block !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  #printDialog::backdrop {
    display: none !important;
  }

  .print-shell,
  .print-workspace {
    display: block !important;
    min-height: 0 !important;
  }

  .print-area {
    overflow: visible !important;
    padding: 0 !important;
  }

  .print-page {
    box-sizing: border-box !important;
    width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 18mm 15mm 16mm !important;
    box-shadow: none !important;
    font-size: 9.5pt !important;
    overflow: hidden !important;
  }

  .print-doc-head {
    grid-template-columns: minmax(0, 1fr) 52mm !important;
    gap: 10mm !important;
    padding-bottom: 11mm !important;
  }

  .print-brand {
    gap: 7mm !important;
  }

  .print-logo-text {
    min-width: 43mm !important;
    padding-top: 8mm !important;
    font-size: 27pt !important;
    line-height: 1 !important;
  }

  .print-brand h2 {
    font-size: 12pt !important;
    margin-bottom: 2mm !important;
  }

  .print-brand p,
  .print-info-grid p,
  .print-note p {
    font-size: 8.5pt !important;
    line-height: 1.45 !important;
  }

  .print-doc-title {
    padding: 2mm 0 2mm 7mm !important;
  }

  .print-doc-title h1 {
    font-size: 18pt !important;
    line-height: 1.15 !important;
  }

  .print-doc-title strong {
    font-size: 14pt !important;
  }

  .print-info-grid,
  .print-bottom-grid {
    grid-template-columns: minmax(0, 1fr) 65mm !important;
    gap: 12mm !important;
    margin-top: 13mm !important;
  }

  .print-info-grid h3,
  .print-note h3 {
    font-size: 10pt !important;
  }

  .print-info-grid h4 {
    font-size: 12pt !important;
  }

  .print-info-grid dl div {
    grid-template-columns: 22mm minmax(0, 1fr) !important;
  }

  .print-items {
    margin-top: 22mm !important;
    font-size: 8.5pt !important;
  }

  .print-items th,
  .print-items td {
    padding: 3mm 2.5mm !important;
  }

  .print-total-box div {
    grid-template-columns: minmax(0, 1fr) 28mm !important;
    padding: 2.5mm 3mm !important;
  }

  .print-signatures {
    gap: 10mm !important;
    margin-top: 18mm !important;
  }

  .print-signatures span {
    height: 12mm !important;
  }

  .print-items th,
  .print-grand {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

@media print {
  .print-page {
    padding: 16mm 14mm 14mm !important;
    font-size: 8.4pt !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .print-doc-head {
    grid-template-columns: minmax(0, 1fr) 46mm !important;
    gap: 8mm !important;
    padding-bottom: 9mm !important;
  }

  .print-logo-text {
    min-width: 34mm !important;
    padding-top: 6mm !important;
    font-size: 21pt !important;
  }

  .print-brand h2 {
    font-size: 10pt !important;
  }

  .print-doc-title h1 {
    font-size: 14pt !important;
  }

  .print-doc-title strong {
    font-size: 11pt !important;
  }

  .print-info-grid,
  .print-bottom-grid {
    grid-template-columns: minmax(0, 1fr) 54mm !important;
    gap: 10mm !important;
    margin-top: 10mm !important;
  }

  .print-info-grid h3,
  .print-note h3 {
    font-size: 8.6pt !important;
  }

  .print-info-grid h4 {
    font-size: 10pt !important;
  }

  .print-brand p,
  .print-info-grid p,
  .print-note p {
    font-size: 7.8pt !important;
  }

  .print-items {
    margin-top: 14mm !important;
    font-size: 7.6pt !important;
  }

  .print-items th,
  .print-items td {
    padding: 2.2mm 2mm !important;
  }

  .print-total-box div {
    grid-template-columns: minmax(0, 1fr) 25mm !important;
    padding: 2mm 2.5mm !important;
  }

  .print-signatures {
    margin-top: auto !important;
    padding-top: 12mm !important;
  }

  .print-signatures span {
    height: 9mm !important;
  }
}

/* Modern print document override */
.print-page {
  width: 900px;
  min-height: 1270px;
  padding: 58px 62px 48px;
  color: #111827;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.045), rgba(255, 255, 255, 0) 150px),
    #fff;
  border: 1px solid #dbe3ee;
  border-radius: 2px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.18);
}

.print-doc-head {
  grid-template-columns: 214px minmax(0, 1fr) 190px;
  align-items: center;
  gap: 18px;
  padding-bottom: 28px;
  border-bottom: 1px solid #d9e1ec;
}

.print-brand {
  display: flex;
  min-width: 0;
  gap: 0;
  align-items: center;
}

.print-logo-text {
  min-width: 76px;
  width: 76px;
  height: 76px;
}

.print-logo-text {
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #bfdbfe;
  border-radius: 18px;
  background: linear-gradient(145deg, #2563eb, #60a5fa);
  color: #fff;
  font-size: 1.72rem;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.2);
}

.print-logo-image {
  display: block;
  min-width: 210px;
  width: 210px;
  height: 56px;
  object-fit: contain;
  object-position: left center;
  border-radius: 0;
}

.print-brand h2 {
  margin: 0 0 7px;
  color: #111827;
  font-size: 1.18rem;
  font-weight: 900;
}

.print-company-info p,
.print-info-grid p,
.print-note p {
  color: #4b5563;
  font-size: 0.68rem;
  line-height: 1.24;
  font-weight: 650;
}

.print-company-info p {
  margin-bottom: 2px;
}

.print-company-info {
  min-width: 0;
}

.print-doc-title {
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 16px 18px;
  border: 1px solid #dbe3ee;
  border-left: 4px solid #2563eb;
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.9);
}

.print-doc-title span {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 900;
}

.print-doc-title h1 {
  margin: 0;
  color: #111827;
  font-size: 1.45rem;
  line-height: 1.15;
}

.print-doc-title strong {
  color: #1d4ed8;
  font-size: 1.02rem;
}

.print-info-grid,
.print-bottom-grid {
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  margin-top: 30px;
}

.print-info-grid h3,
.print-note h3 {
  margin-bottom: 12px;
  color: #1d4ed8;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.print-info-grid h4 {
  margin-bottom: 8px;
  color: #111827;
  font-size: 1rem;
}

.print-info-grid dl div {
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
  padding: 4px 0;
}

.print-info-grid dt {
  color: #64748b;
  font-weight: 800;
}

.print-info-grid dt::after {
  content: ":";
  float: right;
  color: #111827;
  font-weight: 850;
}

.print-info-grid dd {
  color: #111827;
  font-weight: 850;
}

.print-items {
  margin-top: 36px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
}

.print-items th {
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 0.74rem;
  font-weight: 900;
}

.print-items th,
.print-items td {
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid #e5eaf2;
  border-right: 1px solid #e5eaf2;
}

.print-items th:last-child,
.print-items td:last-child {
  border-right: 0;
}

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

.print-items small {
  color: #64748b;
  font-size: 0.7rem;
  line-height: 1.5;
  font-weight: 650;
}

.print-total-box {
  overflow: hidden;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #fff;
}

.print-total-box div {
  grid-template-columns: minmax(0, 1fr) 115px;
  padding: 10px 13px;
  border-bottom: 1px solid #e5eaf2;
}

.print-grand {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #fff;
}

.print-note {
  min-height: 96px;
  padding: 14px 16px;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #f8fafc;
}

.print-signatures {
  gap: 38px;
  padding-top: 44px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.print-signatures span {
  display: block;
  width: 100%;
  height: 18px;
  border-bottom: 1px dashed #6b7280;
}

.print-signatures strong {
  max-width: 100%;
  color: #111827;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.28;
  text-align: center;
}

.print-signatures small {
  color: #6b7280;
  font-size: 0.64rem;
  font-weight: 550;
  line-height: 1.35;
}

.print-signature-slot {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  min-height: 118px;
  text-align: center;
}

.print-signatures .print-signature-slot {
  display: flex;
  align-items: center;
  gap: 2px;
}

.print-signature-slot-media {
  justify-content: center;
}

.print-signatures .print-signature-slot > span {
  width: 100%;
  height: 0;
  margin-bottom: 2px;
  border-bottom: 1px dashed #6b7280;
}

.print-document-footer {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr) minmax(120px, 0.35fr);
  gap: 20px;
  align-items: center;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid #d1d5db;
  color: #6b7280;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.35;
}

.print-document-footer span {
  justify-self: start;
}

.print-document-footer strong {
  grid-column: 2;
  justify-self: center;
  color: #6b7280;
  font-weight: 600;
  text-align: center;
}

.document-style-panel {
  grid-column: 1 / -1;
}

.document-style-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(520px, 1.22fr);
  gap: 20px;
  align-items: start;
}

.document-style-controls {
  display: grid;
  gap: 14px;
}

.document-style-group {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.document-style-group label {
  display: grid;
  gap: 7px;
  color: #374151;
  font-weight: 850;
}

.color-input-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
}

.color-input-row input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

.asset-settings {
  container: asset-settings / inline-size;
}

.asset-settings .settings-row {
  grid-template-columns: minmax(110px, 0.75fr) minmax(0, 1.25fr);
  gap: 10px 16px;
}

.settings-row-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.settings-row-actions .secondary-button {
  min-width: 84px;
}

@container asset-settings (min-width: 680px) {
  .asset-settings .settings-row {
    grid-template-columns: minmax(118px, 0.8fr) minmax(180px, 1.2fr) auto;
    align-items: center;
  }

  .settings-row-actions {
    grid-column: auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
}

.file-action {
  display: inline-grid;
  place-items: center;
}

.toggle-field span {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--blue);
}

.document-style-preview {
  overflow: auto;
  max-height: 760px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%),
    #f8fafc;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.document-preview-shell {
  width: max-content;
  transform: scale(0.72);
  transform-origin: top left;
}

.print-page {
  color: var(--print-text, #111827);
  font-family: var(--print-font, "Noto Sans Thai", Arial, sans-serif);
}

.print-doc-title {
  border-left-color: var(--print-accent, #2563eb);
}

.print-doc-title strong,
.print-info-grid h3,
.print-note h3 {
  color: var(--print-accent, #2563eb);
}

.print-items th,
.print-grand {
  background: var(--print-accent, #2563eb);
  color: #fff;
}

.print-theme-classic .print-doc-title,
.print-theme-classic .print-total-box,
.print-theme-classic .print-note,
.print-theme-classic .print-items {
  border-radius: 0;
}

.print-theme-minimal .print-doc-title {
  border: 0;
  border-left: 3px solid var(--print-accent, #2563eb);
  background: transparent;
}

.print-theme-minimal .print-note,
.print-theme-minimal .print-total-box,
.print-theme-minimal .print-items {
  border-radius: 4px;
  box-shadow: none;
}

.print-stamp-slot,
.print-signatures div {
  position: relative;
}

.print-stamp-image,
.print-signature-image {
  display: block;
  max-width: 118px;
  max-height: 82px;
  margin: 0 auto 4px;
  object-fit: contain;
}

.print-stamp-image {
  opacity: 0.9;
}

.logo-editor-dialog {
  width: min(1080px, calc(100% - 40px));
  max-height: min(84vh, 720px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.logo-editor-dialog::backdrop {
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(3px);
}

.logo-editor-dialog:focus,
.logo-editor-dialog:focus-visible {
  outline: 0;
}

.logo-editor-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(84vh, 720px);
  background: #fff;
}

.logo-editor-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.logo-editor-head h2 {
  font-size: 1.18rem;
  letter-spacing: -0.01em;
}

.logo-editor-head .icon-button {
  width: 36px;
  min-height: 36px;
  border-radius: 10px;
  color: #475569;
  font-size: 1.05rem;
}

.logo-editor-body {
  display: grid;
  grid-template-columns: minmax(440px, 1fr) minmax(440px, 1fr);
  min-height: 0;
  overflow: hidden;
}

.logo-editor-tools,
.logo-editor-preview {
  min-height: 0;
  overflow: auto;
  padding: 14px 18px;
}

.logo-editor-tools {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 8px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.logo-editor-tools h3,
.logo-editor-preview h3 {
  margin: 0;
  color: #111827;
  font-size: 1rem;
}

.logo-editor-tools p {
  max-width: 440px;
  margin: 0;
  color: #6b7280;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.55;
}

.logo-editor-hint {
  color: #2563eb;
  font-size: 0.72rem;
  font-weight: 900;
}

.logo-crop-stage {
  position: relative;
  width: min(100%, 420px);
  min-height: min(118px, 22vw);
  aspect-ratio: 32 / 9;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  cursor: grab;
  touch-action: none;
  background:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%),
    #f8fafc;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.logo-crop-stage:active {
  cursor: grabbing;
}

.logo-size-control {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
  width: min(100%, 420px);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.logo-size-control button {
  min-height: 34px;
  border-radius: 9px;
  padding: 0;
  color: var(--blue);
  font-size: 1.15rem;
}

.logo-size-control label {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: #1f2937;
  font-size: 0.76rem;
  font-weight: 900;
}

.logo-size-control b {
  color: var(--blue);
  font-weight: 900;
}

.logo-size-control input {
  accent-color: var(--blue);
}

#logoEditorImage {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center;
  user-select: none;
  pointer-events: none;
}

.logo-crop-box {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(37, 99, 235, 0.72);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  pointer-events: none;
}

.logo-editor-sliders {
  display: grid;
  width: min(100%, 420px);
  gap: 6px;
}

.logo-editor-sliders label {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: #374151;
  font-size: 0.74rem;
  font-weight: 900;
}

.logo-editor-sliders b {
  color: var(--blue);
  font-weight: 900;
}

.logo-editor-sliders input {
  accent-color: var(--blue);
}

.logo-editor-actions {
  display: grid;
  grid-template-columns: 1fr 0.7fr 1fr;
  gap: 8px;
  width: min(100%, 420px);
  margin: 2px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  background: transparent;
}

.logo-file-button,
#applyLogoEditorButton,
#cancelLogoEditorButton {
  min-height: 38px;
  border-radius: 10px;
}

.logo-file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-align: center;
}

.logo-fit-button {
  min-height: 28px;
  padding: 0 6px;
  border: 0;
  color: var(--blue);
  font-size: 0.74rem;
}

.logo-editor-preview {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 10px;
  border-left: 1px solid #eef2f7;
  background: #f8fafc;
}

.logo-editor-preview .document-preview-shell {
  transform: none;
  zoom: 0.48;
}

@media (max-width: 980px) {
  .logo-editor-dialog,
  .logo-editor-shell {
    max-height: calc(100dvh - 16px);
  }

  .logo-editor-body {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .logo-editor-tools {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .logo-editor-preview .document-preview-shell {
    transform: none;
    zoom: 0.48;
  }

  .logo-editor-actions {
    grid-template-columns: 1fr;
  }
}

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

  .document-style-preview {
    max-height: 640px;
  }
}

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

  .settings-row-actions {
    grid-column: auto;
    justify-content: flex-start;
  }

  .document-style-preview {
    padding: 10px;
  }

  .document-preview-shell {
    transform: scale(0.46);
  }
}

@media print {
  .print-page {
    width: 210mm !important;
    min-height: 297mm !important;
    padding: 15mm 14mm 13mm !important;
    background: #fff !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: #111827 !important;
    font-size: 8.2pt !important;
  }

  .print-doc-head {
    grid-template-columns: 51mm minmax(0, 1fr) 43mm !important;
    align-items: center !important;
    gap: 4mm !important;
    padding-bottom: 8mm !important;
    border-bottom: 0.3mm solid #d9e1ec !important;
  }

  .print-brand {
    align-items: center !important;
    gap: 0 !important;
  }

  .print-logo-text {
    min-width: 17mm !important;
    width: 17mm !important;
    height: 17mm !important;
    border-radius: 4mm !important;
  }

  .print-logo-image {
    min-width: 50mm !important;
    width: 50mm !important;
    height: 13.5mm !important;
    border-radius: 0 !important;
    object-fit: contain !important;
    object-position: left center !important;
  }

  .print-logo-text {
    font-size: 14pt !important;
    box-shadow: none !important;
  }

  .print-brand h2 {
    font-size: 10.5pt !important;
  }

  .print-company-info p,
  .print-info-grid p,
  .print-note p {
    font-size: 6.4pt !important;
    line-height: 1.18 !important;
  }

  .print-company-info p {
    margin-bottom: 0.7mm !important;
  }

  .print-doc-title {
    gap: 1.6mm !important;
    padding: 4mm !important;
    border-radius: 3mm !important;
    border-left: 1mm solid var(--print-accent, #2563eb) !important;
  }

  .print-doc-title h1 {
    font-size: 13pt !important;
  }

  .print-doc-title strong {
    font-size: 9.8pt !important;
  }

  .print-info-grid,
  .print-bottom-grid {
    grid-template-columns: minmax(0, 1fr) 54mm !important;
    gap: 9mm !important;
    margin-top: 8mm !important;
  }

  .print-info-grid h3,
  .print-note h3 {
    margin-bottom: 2.5mm !important;
    font-size: 7pt !important;
  }

  .print-info-grid h4 {
    font-size: 9.2pt !important;
  }

  .print-info-grid dl div {
    grid-template-columns: 16mm minmax(0, 1fr) !important;
    gap: 2.2mm !important;
    padding: 0.8mm 0 !important;
  }

  .print-items {
    margin-top: 9mm !important;
    border-radius: 3mm !important;
    font-size: 7.4pt !important;
  }

  .print-items th,
  .print-items td {
    padding: 2mm 2.2mm !important;
  }

  .print-items small {
    font-size: 6.6pt !important;
  }

  .print-note {
    min-height: 20mm !important;
    padding: 3mm !important;
    border-radius: 3mm !important;
  }

  .print-total-box {
    border-radius: 3mm !important;
  }

  .print-total-box div {
    grid-template-columns: minmax(0, 1fr) 25mm !important;
    padding: 2mm 2.5mm !important;
  }

  .print-signatures {
    gap: 9mm !important;
    margin-top: auto !important;
    padding-top: 11mm !important;
  }

  .print-signatures span {
    height: 8mm !important;
  }

  .print-logo-text,
  .print-logo-image,
  .print-items th,
  .print-grand {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-page {
    color: var(--print-text, #111827) !important;
    font-family: var(--print-font, "Noto Sans Thai", Arial, sans-serif) !important;
  }

  .print-doc-title strong,
  .print-info-grid h3,
  .print-note h3 {
    color: var(--print-accent, #2563eb) !important;
  }

  .print-items th,
  .print-grand {
    background: var(--print-accent, #2563eb) !important;
    color: #fff !important;
  }
}

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

  .project-summary-grid .metric-card {
    min-height: 72px;
  }

  .project-secondary-card {
    display: none;
  }

  .project-filter-bar.toolbar {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
  }

  .project-table-wrap {
    display: none;
  }

  .project-list-cards {
    display: grid;
  }

  .project-panel .table-meta {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.82rem;
  }
}

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

  .project-summary-grid .metric-card {
    min-height: 64px;
    padding: 9px 10px;
  }

  .project-summary-grid .metric-card strong {
    font-size: 1.1rem;
  }

  .project-summary-grid .metric-card small {
    display: none;
  }

  .project-filter-bar.toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-filter-bar label:nth-of-type(2),
  .project-filter-bar label:nth-of-type(4),
  .project-filter-bar label:nth-of-type(5),
  .project-filter-bar label:nth-of-type(6) {
    display: none;
  }

  .project-search-field,
  .project-filter-bar .plain-button {
    grid-column: 1 / -1;
  }

  .project-filter-bar select,
  .project-filter-bar .plain-button,
  .project-search-field {
    min-height: 38px;
  }

  .project-panel .tabs {
    padding: 8px 8px 6px;
  }

  .project-panel .tab-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  .project-card {
    gap: 8px;
    padding: 10px;
  }

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

  .project-card-secondary {
    display: none !important;
  }

  .project-card-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .project-card-actions button {
    min-height: 34px;
    font-size: 0.74rem;
  }
}

@media (max-width: 560px) {
  .project-filter-bar label > span {
    display: none;
  }

  .project-panel .table-meta {
    display: none;
  }
}

@media screen {
  #printDialog.print-dialog {
    width: min(1040px, calc(100% - 48px));
    height: min(86dvh, 760px);
    max-height: min(86dvh, 760px);
  }

  #printDialog .print-shell,
  #printDialog .print-workspace {
    height: 100%;
    max-height: min(86dvh, 760px);
  }

  #printDialog .print-toolbar {
    min-height: 64px;
    padding: 10px 18px;
  }

  #printDialog .print-toolbar strong {
    font-size: 0.96rem;
  }

  #printDialog .print-options {
    gap: 8px;
  }

  #printDialog .print-options label {
    min-height: 38px;
    gap: 6px;
    padding: 0 6px;
    font-size: 0.9rem;
    line-height: 1;
  }

  #printDialog .print-options input[type="checkbox"] {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    margin: 0;
    accent-color: var(--blue);
  }

  #printDialog .print-options button {
    min-height: 40px;
    padding: 0 16px;
  }

  #printDialog .print-area {
    padding: 18px;
  }

  #printDialog .print-page {
    width: 800px;
    min-height: 1130px;
    padding: 42px 48px 40px;
  }
}

@media screen and (max-width: 760px) {
  #printDialog.print-dialog {
    width: calc(100% - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
  }

  #printDialog .print-shell,
  #printDialog .print-workspace {
    max-height: calc(100dvh - 16px);
  }

  #printDialog .print-toolbar {
    min-height: auto;
    padding: 10px;
  }

  #printDialog .print-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #printDialog .print-options label,
  #printDialog .print-options button {
    min-height: 38px;
    font-size: 0.84rem;
  }

  #printDialog .print-area {
    padding: 10px;
  }

  #printDialog .print-page {
    width: 210mm;
    min-width: 210mm;
    min-height: 297mm;
    padding: 12mm;
  }
}
