/*
 * Smart ERP unified UI polish
 * Loaded after the historical module styles so every workspace page shares
 * one visual language without coupling presentation changes to business code.
 */

:root {
  --ui-primary: #5147e5;
  --ui-primary-dark: #3e35bf;
  --ui-primary-soft: #f0efff;
  --ui-text: #17243a;
  --ui-text-soft: #64738a;
  --ui-text-faint: #929daf;
  --ui-border: #e1e6ef;
  --ui-border-strong: #d6dde9;
  --ui-page: #f5f7fb;
  --ui-panel: #fff;
  --ui-panel-soft: #fafbfe;
  --ui-success: #098966;
  --ui-warning: #c87308;
  --ui-danger: #cf3348;
  --ui-radius: 16px;
  --ui-radius-sm: 10px;
  --ui-shadow: 0 10px 30px rgba(24, 39, 70, .055);
  --ui-shadow-raised: 0 18px 46px rgba(24, 39, 70, .10);
}

/* Administration / personnel records */
.employee-hero{display:flex;align-items:center;justify-content:space-between;gap:24px;padding:25px 28px;border:1px solid #dde5f0;border-radius:22px;background:linear-gradient(135deg,#fff 0%,#f6f8ff 100%);box-shadow:0 14px 34px rgba(30,55,90,.07)}
.employee-hero-copy{display:flex;align-items:center;gap:16px}.employee-hero-copy>i{display:grid;place-items:center;width:54px;height:54px;border-radius:17px;background:linear-gradient(135deg,#e9e7ff,#f4f2ff);color:#5146e5;font-size:22px;font-style:normal;font-weight:800}.employee-hero h3{margin:4px 0 0;font-size:23px;color:#16243b}.employee-hero .eyebrow{color:#6558e8;font-size:11px;font-weight:800;letter-spacing:1.8px}
.employee-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin:18px 0}.employee-summary>div{display:flex;flex-direction:column;min-height:105px;padding:20px 22px;border:1px solid #dde5f0;border-radius:18px;background:#fff;box-shadow:0 10px 28px rgba(30,55,90,.05)}.employee-summary span{color:#70809a;font-size:13px}.employee-summary strong{margin:8px 0 3px;color:#172d50;font-size:28px}.employee-summary small{color:#95a1b3;font-size:12px}
.employee-panel{overflow:hidden}.employee-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:12px 16px;border-bottom:1px solid #e6ebf3;background:#fbfcff}.employee-search{display:flex;align-items:center;flex:0 1 470px;min-width:300px;min-height:42px;border:1px solid #d8e0ec;border-radius:12px;background:#fff;padding-left:12px;transition:border-color .2s,box-shadow .2s}.employee-search:focus-within{border-color:#766af0;box-shadow:0 0 0 4px rgba(97,83,231,.1)}.employee-search>span{color:#7d8ba1;font-size:18px}.employee-search input{min-width:0;flex:1;border:0!important;box-shadow:none!important;background:transparent!important;padding:9px 10px!important}.employee-search button{align-self:stretch;margin:3px;border-radius:9px}.employee-toolbar>select{width:auto;min-width:136px;height:42px;padding-top:0;padding-bottom:0}.employee-io-actions{display:flex;gap:8px;margin-left:auto}.employee-io-actions button{height:42px;white-space:nowrap}.employee-empty.polished-empty{min-height:148px!important;padding:28px 20px!important}.employee-empty.polished-empty:before{width:42px;height:42px;margin-bottom:10px}.employee-panel>.server-pager{margin-top:0;border-top:1px solid #e6ebf3}
.employee-table-shell{border:0;border-radius:0}.employee-table{min-width:1120px}.employee-table th{background:#f7f9fd;color:#66758c;font-size:12px;white-space:nowrap}.employee-table td{vertical-align:middle}.employee-table td>strong,.employee-table td>small{display:block}.employee-table td>small{margin-top:5px;color:#8b98ab}.employee-name-cell{display:flex;align-items:center;gap:10px}.employee-name-cell i{display:grid;place-items:center;width:36px;height:36px;border-radius:12px;background:#eeecff;color:#574be5;font-style:normal;font-weight:800}.employee-name-cell strong{color:#1c2c44}.employee-status,.employee-account{display:inline-flex;align-items:center;justify-content:center;padding:5px 10px;border-radius:999px;font-size:12px;font-weight:700}.employee-status.active{background:#e7f7ef;color:#14835d}.employee-status.left{background:#fff3df;color:#a86710}.employee-status.disabled{background:#eef1f6;color:#6d788a}.employee-account{background:#edf3ff;color:#315da8}.employee-form .master-form-intro>i{background:#eeecff;color:#574be5}
@media(max-width:900px){.employee-summary{grid-template-columns:1fr}.employee-hero{align-items:flex-start;flex-direction:column}.employee-toolbar{align-items:stretch;flex-direction:column}.employee-search{width:100%;max-width:none;min-width:0}.employee-io-actions{margin-left:0}.employee-toolbar>select{width:100%}}

html,
body {
  min-width: 320px;
  min-height: 100%;
}

body {
  color: var(--ui-text);
  background:
    radial-gradient(circle at 79% 0, rgba(97, 86, 225, .07), transparent 28%),
    linear-gradient(180deg, #f7f9fc 0, var(--ui-page) 100%);
}

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

main {
  width: 100%;
  min-width: 0;
  padding: 25px clamp(22px, 2.5vw, 42px) 46px;
}

.page {
  min-width: 0;
  padding-bottom: 24px;
  animation: ui-page-in .2s ease-out;
}

@keyframes ui-page-in {
  from { opacity: .55; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Top workspace bar */
.topbar {
  min-height: 78px;
  align-items: center;
  margin: 0 0 20px;
  padding: 0 2px 17px;
  border-bottom: 1px solid var(--ui-border-strong);
}

.topbar .eyebrow {
  margin-bottom: 4px;
  color: #7169e8;
  font-size: 10px;
  letter-spacing: .16em;
}

.topbar h2 {
  margin: 0;
  color: #10203a;
  font-size: clamp(24px, 2.1vw, 31px);
  line-height: 1.2;
  letter-spacing: -.035em;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 18px;
}

.system-online {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid #cfe8df;
  border-radius: 999px;
  background: #f2fbf7;
  color: #08795a;
  font-size: 11px;
  font-weight: 800;
}

.sidebar-account-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sidebar-account-actions .link {
  padding: 7px 5px;
  font-size: 11px;
  white-space: nowrap;
}

.account-password-form .hint {
  display: flex;
  margin-bottom: 18px;
  padding: 14px 16px;
  flex-direction: column;
  gap: 4px;
  border: 1px solid #dfe3ff;
  border-left: 3px solid var(--ui-primary);
  border-radius: 11px;
  background: #f7f7ff;
}

.account-password-form .hint strong { color: #312b8f; }
.account-password-form .hint span { color: var(--ui-text-soft); }

.system-online i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #12ad80;
  box-shadow: 0 0 0 5px rgba(18, 173, 128, .11);
}

.topbar .date {
  padding-left: 18px;
  border-left: 1px solid var(--ui-border);
  color: #6d7c94;
  font-size: 12px;
  white-space: nowrap;
}

/* Sidebar hierarchy */
.sidebar {
  z-index: 20;
  border-right: 1px solid rgba(255, 255, 255, .045);
  background:
    radial-gradient(circle at 12% 0, rgba(100, 91, 225, .24), transparent 27%),
    linear-gradient(180deg, #12192d, #0f1729 72%);
  box-shadow: 12px 0 38px rgba(18, 27, 48, .08);
}

.sidebar nav {
  min-height: 0;
  padding-right: 3px;
  overflow-x: hidden;
  overflow-y: auto;
}

.sidebar nav::-webkit-scrollbar { width: 5px; }
.sidebar nav::-webkit-scrollbar-thumb { border: 0; background: #536078; }

.sidebar nav button,
.nav-section-toggle {
  min-height: 43px;
  border: 1px solid transparent;
  border-radius: 11px;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}

.sidebar nav button:hover {
  border-color: rgba(145, 151, 255, .10);
  background: rgba(110, 105, 218, .11);
}

.sidebar nav button.active {
  border-color: rgba(143, 137, 255, .24);
  background: linear-gradient(90deg, rgba(90, 80, 220, .34), rgba(74, 67, 173, .18));
  box-shadow: inset 3px 0 #756cff;
}

.nav-section-items {
  margin: 3px 0 6px 12px;
  padding-left: 8px;
  border-left: 1px solid rgba(180, 186, 217, .13);
}

.sidebar-foot {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 16px 5px 0;
}

.sidebar-foot .link {
  padding: 7px;
  border-radius: 8px;
}

/* Shared page headers */
.business-page-head,
.module-hero,
.dashboard-hero,
.bom-hero,
.basic-list-hero,
.administration-head,
.print-config-hero,
.config-page-head,
.site-report-head {
  min-width: 0;
  border: 1px solid var(--ui-border) !important;
  border-radius: var(--ui-radius) !important;
  background: linear-gradient(120deg, #fff 57%, #f8f8ff) !important;
  color: var(--ui-text) !important;
  box-shadow: var(--ui-shadow) !important;
}

.business-page-head,
.module-hero,
.dashboard-hero,
.bom-hero,
.basic-list-hero,
.site-report-head {
  min-height: 86px !important;
  padding: 18px 21px !important;
}

.business-page-head::after,
.module-hero::after,
.dashboard-hero::after,
.bom-hero::after { display: none !important; }

.business-page-head h3,
.module-hero h3,
.dashboard-hero h3,
.bom-hero h3,
.basic-list-hero h3,
.site-report-head h3,
.administration-head h3 {
  margin: 0 0 4px !important;
  color: var(--ui-text) !important;
  font-size: 18px !important;
  line-height: 1.35;
}

.business-page-head p,
.module-hero p,
.dashboard-hero p,
.bom-hero p,
.basic-list-hero p,
.site-report-head p,
.administration-head p {
  max-width: 860px;
  margin: 0 !important;
  color: var(--ui-text-soft) !important;
  font-size: 11px !important;
  line-height: 1.65;
}

.business-page-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, #ecebff, #f4f3ff);
  color: var(--ui-primary);
  font-size: 16px;
  font-style: normal;
  font-weight: 900;
}

.business-page-note {
  min-width: 170px;
  padding-left: 18px;
  border-left-color: var(--ui-border);
}

.business-page-head > .primary,
.module-hero > .primary,
.module-hero .hero-action,
.bom-hero > .primary,
.site-report-head > .primary {
  flex: 0 0 auto;
  margin-left: auto;
}

/* Surfaces and metric cards */
.panel,
.stat,
.module-summary > div,
.req-mini-summary > div,
.bom-summary > div,
.procurement-kpis > div,
.comparison-summary > div,
.administration-summary > div,
.site-report-summary > div,
.data-card {
  border: 1px solid var(--ui-border) !important;
  border-radius: var(--ui-radius) !important;
  background: var(--ui-panel);
  box-shadow: var(--ui-shadow) !important;
}

.panel {
  margin-top: 16px;
}

.module-panel,
.bom-panel,
.administration-panel,
.comparison-panel,
.order-list-panel,
.requisition-list-panel {
  overflow: hidden;
  padding: 0;
}

.panel-head {
  min-width: 0;
  min-height: 67px;
  gap: 16px;
  margin: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ui-border);
  background: #fff;
}

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

.panel-head h3 {
  margin: 0 0 3px;
  color: var(--ui-text);
  font-size: 15px;
}

.panel-head .muted,
.panel-head p,
.panel-head span {
  color: var(--ui-text-soft);
  font-size: 10px;
  line-height: 1.55;
}

.stats,
.module-summary,
.bom-summary,
.procurement-kpis,
.comparison-summary,
.administration-summary,
.site-report-summary {
  gap: 13px !important;
  margin-top: 14px !important;
}

.stat,
.module-summary > div,
.bom-summary > div,
.procurement-kpis > div,
.comparison-summary > div,
.administration-summary > div,
.site-report-summary > div {
  min-width: 0;
  min-height: 104px !important;
  padding: 17px 19px !important;
}

.stat span,
.module-summary span,
.bom-summary span,
.procurement-kpis span,
.comparison-summary span,
.administration-summary span,
.site-report-summary span {
  color: var(--ui-text-soft);
  font-size: 10px;
}

.stat strong,
.module-summary strong,
.bom-summary strong,
.procurement-kpis strong,
.comparison-summary strong,
.administration-summary strong,
.site-report-summary strong {
  color: #18365d;
  font-size: clamp(23px, 2vw, 29px);
  letter-spacing: -.03em;
}

/* Toolbars and filters */
.toolbar,
.data-table-tools,
.basic-list-toolbar,
.bom-toolbar,
.procurement-toolbar,
.administration-toolbar,
.document-filter-bar,
.sales-outbound-toolbar,
.site-report-toolbar {
  min-width: 0;
  gap: 10px;
  padding: 12px 16px;
  border-color: var(--ui-border) !important;
  background: var(--ui-panel-soft) !important;
}

.data-table-tools {
  min-height: 61px;
  border-top: 0;
}

.data-table-search,
.basic-search,
.procurement-search,
.administration-toolbar .search-box,
.document-filter-search {
  height: 40px;
  border: 1px solid var(--ui-border-strong) !important;
  border-radius: var(--ui-radius-sm) !important;
  background: #fff !important;
  box-shadow: none !important;
}

.data-table-search:focus-within,
.basic-search:focus-within,
.procurement-search:focus-within,
.administration-toolbar .search-box:focus-within,
.document-filter-search:focus-within {
  border-color: #847ced !important;
  box-shadow: 0 0 0 3px rgba(81, 71, 229, .09) !important;
}

.data-table-search input,
.basic-search input,
.procurement-search input,
.administration-toolbar .search-box input,
.document-filter-search input {
  min-width: 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.data-table-sort-hint,
.administration-filter-note {
  color: var(--ui-text-faint);
  font-size: 10px;
}

/* Buttons */
.primary,
.ghost,
.danger,
button.primary,
button.ghost,
button.danger {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  white-space: nowrap;
}

.primary {
  border: 1px solid transparent;
  background: linear-gradient(135deg, #5c53ee, #4438cf);
  box-shadow: 0 6px 14px rgba(76, 64, 210, .17);
}

.primary:hover {
  background: linear-gradient(135deg, #5047e5, #392fb8);
  box-shadow: 0 9px 20px rgba(76, 64, 210, .24);
}

.ghost {
  border: 1px solid var(--ui-border-strong);
  background: #fff;
  color: #46566e;
}

.ghost:hover {
  border-color: #c8cfdd;
  background: #f5f7fb;
  color: #26364f;
}

.danger {
  border: 1px solid #f1d7dc;
  background: #fff5f6;
  color: var(--ui-danger);
}

.danger:hover { background: #ffecef; }

button:disabled {
  box-shadow: none !important;
  opacity: .48;
}

.row-actions {
  min-width: max-content;
  align-items: center;
  gap: 6px;
}

.row-actions .primary,
.row-actions .ghost,
.row-actions .danger,
td > .primary,
td > .ghost,
td > .danger {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 10px;
}

/* Tables */
.table-shell,
.table-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  background: #fff;
  scrollbar-color: #c4ccd8 transparent;
  scrollbar-width: thin;
}

.table-shell table,
.table-wrap table {
  width: 100%;
  min-width: 880px;
  border-spacing: 0;
  border-collapse: separate;
  table-layout: auto;
}

table {
  color: #35445b;
  font-size: 11px;
}

thead th {
  position: relative;
  height: 48px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--ui-border);
  background: #f7f8fc;
  color: #65738a;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
}

tbody td {
  height: 58px;
  padding: 11px 13px;
  border-bottom: 1px solid #edf0f5;
  color: #35445b;
  vertical-align: middle;
}

tbody tr:nth-child(even) { background: #fcfdff; }
tbody tr:hover { background: #f8f8ff !important; }
tbody tr:last-child td { border-bottom: 0; }

td strong { color: #20314b; }
td small,
td .muted {
  color: #8793a5;
  font-size: 9px;
  line-height: 1.5;
}

.table-sortable:hover { background: #efefff !important; }
.table-sortable::after { right: 7px; }

.status,
.chip,
.scope-chip,
.price-enabled,
.administration-type {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.owner-identity {
  min-width: 145px;
}

.owner-identity i {
  box-shadow: inset 0 0 0 1px rgba(81, 71, 229, .08);
}

/* Pagination */
.data-pager,
.client-pager,
.server-pager {
  min-height: 62px;
  margin: 0 !important;
  padding: 12px 16px;
  border-top: 1px solid var(--ui-border);
  background: #fbfcfe;
}

.pager-controls select,
.pager-controls input {
  height: 36px;
  border-color: var(--ui-border-strong);
  border-radius: 9px;
}

.pager-controls .ghost {
  min-height: 36px;
}

/* Forms */
.form-grid {
  gap: 16px 18px;
}

.form-grid label,
.administration-form label,
.config-fields label,
.print-config-fields label {
  color: #526178;
  font-size: 10px;
  font-weight: 800;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  border: 1px solid var(--ui-border-strong);
  border-radius: 9px;
  background: #fbfcfe;
  color: var(--ui-text);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover,
select:hover,
textarea:hover {
  border-color: #c3ccda;
  background: #fff;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
select:focus,
textarea:focus {
  border-color: #8179ea !important;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(81, 71, 229, .09) !important;
}

input::placeholder,
textarea::placeholder { color: #a1aaba; }

textarea {
  min-height: 96px;
  line-height: 1.65;
  resize: vertical;
}

.form-actions {
  gap: 8px;
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid #edf0f4;
}

.required-indicator {
  margin-left: 3px;
  color: #e03950;
}

.hint {
  border: 1px solid #deddf9;
  border-left: 3px solid var(--ui-primary);
  border-radius: 10px;
  background: #f8f8ff;
  color: #53627a;
  font-size: 10px;
}

/* Dialogs */
dialog {
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  border: 1px solid rgba(225, 230, 239, .75);
  border-radius: 19px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(12, 24, 48, .24);
}

dialog::backdrop {
  background: rgba(15, 23, 42, .58);
  backdrop-filter: blur(3px);
}

#dialog[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dialog-head {
  position: relative;
  z-index: 3;
  min-height: 70px;
  flex: 0 0 auto;
  padding: 16px 21px;
  border-bottom: 1px solid var(--ui-border);
  background: rgba(255, 255, 255, .96);
}

.dialog-head h3 {
  color: var(--ui-text);
  font-size: 17px;
}

.dialog-head button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  font-size: 22px;
}

.dialog-head button:hover {
  background: #f1f3f7;
  color: #293950;
}

#dialogBody {
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
  padding: 21px;
  overflow-x: hidden;
  overflow-y: auto;
}

.toast {
  z-index: 1000;
  top: 20px;
  right: 24px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 11px;
  background: #243753;
  box-shadow: 0 16px 38px rgba(22, 36, 59, .22);
  font-size: 11px;
  line-height: 1.55;
}

.toast.error { background: #ad2d41; }

/* Empty and loading states */
.panel > .empty,
.module-panel > .empty,
.table-shell > .empty,
.page > .empty,
.admin-empty {
  min-height: 210px;
  padding: 60px 24px;
  color: var(--ui-text-soft);
  background:
    radial-gradient(circle at 50% 44%, rgba(81, 71, 229, .055), transparent 16%),
    #fff;
}

.panel > .empty::before,
.module-panel > .empty::before,
.page > .empty::before {
  display: block;
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  border: 1px solid #dfdefb;
  border-radius: 13px;
  background: #f3f2ff;
  color: #6961de;
  content: "· · ·";
  font-size: 16px;
  font-weight: 900;
  line-height: 38px;
  text-align: center;
}

td.empty::before { display: none; }

/* Legacy pages without a dedicated hero */
#page-security > .panel:first-child,
#page-tableBuilder > .panel:first-child,
#page-audit > .panel:first-child {
  margin-top: 0;
}

#page-security .security-intro,
#page-tableBuilder > .panel:first-child {
  padding: 18px 20px;
  background: linear-gradient(120deg, #fff 55%, #f8f8ff);
}

#page-security .organization-grid,
#page-tableBuilder .card-grid {
  padding: 18px;
}

/* Login receives the same design language */
.login-shell {
  grid-template-columns: minmax(0, 1fr) minmax(380px, 450px);
  gap: clamp(36px, 6vw, 88px);
  padding: clamp(34px, 7vw, 110px);
  background:
    radial-gradient(circle at 18% 18%, rgba(114, 105, 238, .16), transparent 31%),
    radial-gradient(circle at 88% 84%, rgba(36, 151, 220, .10), transparent 28%),
    #f4f7fc;
}

.login-showcase-copy h2 {
  color: #14233b;
  letter-spacing: -.04em;
}

.login-card {
  padding: 34px;
  border: 1px solid rgba(222, 227, 238, .9);
  border-radius: 24px;
  box-shadow: 0 26px 70px rgba(30, 43, 69, .14);
}

.login-card input {
  min-height: 46px;
  padding: 0 13px;
}

/* Responsive layout */
@media (max-width: 1260px) {
  .app-shell { grid-template-columns: 224px minmax(0, 1fr); }
  main { padding-right: 24px; padding-left: 24px; }
  .sidebar { padding-right: 12px; padding-left: 12px; }
  .business-page-note { min-width: 145px; }
}

@media (max-width: 1040px) {
  .stats,
  .module-summary,
  .bom-summary,
  .procurement-kpis,
  .comparison-summary,
  .administration-summary,
  .site-report-summary { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  .business-page-head,
  .module-hero,
  .bom-hero,
  .site-report-head { flex-wrap: wrap; }

  .business-page-note {
    min-width: 0;
    margin-left: auto;
  }
}

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

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    max-height: none;
    padding: 14px;
  }

  .sidebar .brand { padding-bottom: 13px; }
  .sidebar nav { max-height: 42vh; }
  .sidebar-foot { display: grid; }

  main { padding: 20px 16px 34px; }

  .topbar { min-height: 67px; }
  .topbar .eyebrow { display: none; }
  .topbar h2 { font-size: 24px; }

  .login-shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 24px;
  }

  .login-showcase { display: none; }
  .login-card { width: min(100%, 480px); margin: auto; }
}

@media (max-width: 700px) {
  main { padding: 15px 11px 30px; }

  .topbar {
    align-items: flex-start;
    gap: 10px;
  }

  .topbar-meta { gap: 7px; }
  .topbar .date { display: none; }
  .system-online { min-height: 28px; padding: 0 9px; font-size: 9px; }

  .business-page-head,
  .module-hero,
  .dashboard-hero,
  .bom-hero,
  .basic-list-hero,
  .site-report-head,
  .administration-head {
    align-items: flex-start !important;
    flex-direction: column !important;
    padding: 16px !important;
  }

  .business-page-note {
    width: 100%;
    margin: 4px 0 0;
    padding: 10px 0 0;
    border-top: 1px solid var(--ui-border);
    border-left: 0;
  }

  .business-page-head > .primary,
  .module-hero > .primary,
  .module-hero .hero-action,
  .bom-hero > .primary,
  .site-report-head > .primary {
    width: 100%;
    margin-left: 0;
  }

  .stats,
  .module-summary,
  .bom-summary,
  .procurement-kpis,
  .comparison-summary,
  .administration-summary,
  .site-report-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px !important;
  }

  .stat,
  .module-summary > div,
  .bom-summary > div,
  .procurement-kpis > div,
  .comparison-summary > div,
  .administration-summary > div,
  .site-report-summary > div {
    min-height: 88px !important;
    padding: 13px !important;
  }

  .panel-head,
  .toolbar,
  .data-table-tools,
  .basic-list-toolbar,
  .bom-toolbar,
  .procurement-toolbar,
  .administration-toolbar,
  .document-filter-bar,
  .sales-outbound-toolbar,
  .site-report-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-head > button,
  .panel-head > .actions,
  .toolbar > button,
  .toolbar > .actions,
  .data-table-search,
  .basic-search,
  .procurement-search,
  .administration-toolbar .search-box {
    width: 100%;
    max-width: none;
  }

  .panel-head > .actions,
  .toolbar > .actions { display: grid; grid-template-columns: 1fr 1fr; }

  .data-table-sort-hint { margin-left: 0; }

  .data-pager,
  .client-pager,
  .server-pager {
    align-items: flex-start;
    flex-direction: column;
  }

  .pager-controls { width: 100%; }
  .pager-controls .ghost { flex: 1; }

  dialog {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    margin: auto;
    border-radius: 16px;
  }

  .dialog-head { min-height: 60px; padding: 13px 15px; }
  #dialogBody { padding: 15px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }

  .toast {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }

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

@media (max-width: 430px) {
  .stats,
  .module-summary,
  .bom-summary,
  .procurement-kpis,
  .comparison-summary,
  .administration-summary,
  .site-report-summary { grid-template-columns: 1fr !important; }

  .panel-head > .actions,
  .toolbar > .actions { grid-template-columns: 1fr; }
}

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

/* Searchable multi-select material picker */
.batch-picker-dialog {
  width: min(940px, calc(100vw - 34px));
  max-width: min(940px, calc(100vw - 34px));
  max-height: min(820px, calc(100dvh - 34px));
  padding: 0;
  overflow: hidden;
}

.batch-picker-dialog[open] {
  display: flex;
  flex-direction: column;
}

.batch-picker-head {
  display: flex;
  min-height: 82px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--ui-border);
  background: linear-gradient(120deg, #fff 55%, #f6f5ff);
}

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

.batch-picker-head span {
  color: #7169dc;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .14em;
}

.batch-picker-head h3 {
  margin: 3px 0 2px;
  color: var(--ui-text);
  font-size: 18px;
}

.batch-picker-head p {
  margin: 0;
  color: var(--ui-text-soft);
  font-size: 10px;
}

.batch-picker-head > button {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: #f0f2f6;
  color: #758095;
  font-size: 22px;
  cursor: pointer;
}

.batch-picker-head > button:hover {
  background: #e8eaf0;
  color: #26354b;
}

.batch-picker-toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ui-border);
  background: #fafbfe;
}

.batch-picker-search {
  display: flex;
  min-width: 260px;
  max-width: 520px;
  height: 41px;
  flex: 1;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 10px;
  background: #fff;
}

.batch-picker-search:focus-within {
  border-color: #827aec;
  box-shadow: 0 0 0 3px rgba(81, 71, 229, .09);
}

.batch-picker-search > span {
  color: #8c97a8;
  font-size: 16px;
}

.batch-picker-search input {
  width: 100%;
  height: 38px;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.batch-picker-type-filter {
  min-width: 126px;
  height: 41px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 10px;
  background: #fff;
  color: #526077;
  font-size: 10px;
}

.batch-picker-type-filter:focus {
  border-color: #827aec;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(81, 71, 229, .09);
}

.batch-picker-list {
  display: grid;
  min-height: 240px;
  flex: 1 1 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 10px;
  padding: 15px 16px;
  overflow-y: auto;
  background: #fff;
}

.batch-picker-item {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 86px;
  grid-template-columns: 20px 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e2e6ed;
  border-radius: 13px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}

.batch-picker-item:hover {
  border-color: #ccc9f5;
  background: #fdfdff;
  transform: translateY(-1px);
  box-shadow: 0 7px 18px rgba(34, 45, 74, .06);
}

.batch-picker-item.selected {
  border-color: #9c96ef;
  background: #f7f6ff;
  box-shadow: inset 0 0 0 1px rgba(81, 71, 229, .08);
}

.batch-picker-item > input {
  width: 17px;
  height: 17px;
  accent-color: var(--ui-primary);
}

.batch-picker-item > i {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: #eeedff;
  color: #5148d8;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.batch-picker-item > span {
  min-width: 0;
}

.batch-picker-item strong,
.batch-picker-item small,
.batch-picker-item em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-picker-item strong {
  color: #283850;
  font-size: 11px;
}

.batch-picker-item small {
  margin-top: 3px;
  color: #738096;
  font-size: 9px;
}

.batch-picker-item em {
  margin-top: 4px;
  color: #9aa3b1;
  font-size: 8px;
  font-style: normal;
}

.batch-picker-item > b {
  align-self: start;
  padding: 5px 7px;
  border-radius: 999px;
  background: #eef2f8;
  color: #647189;
  font-size: 8px;
  white-space: nowrap;
}

.batch-picker-empty {
  display: flex;
  min-height: 260px;
  grid-column: 1/-1;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #8490a3;
}

.batch-picker-empty i {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 11px;
  place-items: center;
  border-radius: 14px;
  background: #f0efff;
  color: #5b53d9;
  font-size: 19px;
  font-style: normal;
}

.batch-picker-empty strong { color: #536177; font-size: 12px; }
.batch-picker-empty span { margin-top: 4px; font-size: 9px; }

.batch-picker-footer {
  display: flex;
  min-height: 70px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 17px;
  border-top: 1px solid var(--ui-border);
  background: #fafbfe;
}

.batch-picker-footer > div:first-child strong,
.batch-picker-footer > div:first-child small {
  display: block;
}

.batch-picker-footer > div:first-child strong {
  color: #293951;
  font-size: 11px;
}

.batch-picker-footer > div:first-child strong span { color: var(--ui-primary); }
.batch-picker-footer > div:first-child small { margin-top: 3px; color: #8b96a7; font-size: 9px; }
.batch-picker-footer > div:last-child { display: flex; gap: 8px; }

.direct-req-head .material-count {
  display: inline-flex;
  margin-left: 7px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eeedff;
  color: #564dd5;
  font-size: 9px;
  vertical-align: middle;
}

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

.material-lines-empty {
  display: flex;
  min-height: 150px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border-top: 1px solid #edf0f4;
  background: #fbfcfe;
  color: #8490a2;
}

.material-lines-empty > i {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 9px;
  place-items: center;
  border-radius: 13px;
  background: #eeedff;
  color: #554cd4;
  font-style: normal;
  font-weight: 900;
}

.material-lines-empty > strong { color: #536178; font-size: 11px; }
.material-lines-empty > span { margin-top: 4px; font-size: 9px; }

.direct-req-table table { min-width: 1020px; }
.direct-req-table:has(tbody:empty) { display: none; }

.selected-material-cell,
.selected-product-cell {
  min-width: 180px;
}

.selected-material-cell strong,
.selected-material-cell small,
.selected-product-cell strong,
.selected-product-cell small {
  display: block;
}

.selected-material-cell strong,
.selected-product-cell strong {
  color: #263850;
  font-size: 11px;
}

.selected-material-cell small,
.selected-product-cell small {
  margin-top: 4px;
  color: #7f8b9e;
  font-size: 9px;
}

.req-material-search {
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 9px;
  padding: 8px 13px;
  border: 1px solid var(--ui-border);
  border-bottom: 0;
  border-radius: 11px 11px 0 0;
  background: #fafbfe;
}

.req-material-search > span {
  color: #8792a4;
  font-size: 16px;
}

.req-material-search input {
  width: min(440px, 100%);
  height: 37px;
  padding: 0 11px;
  background: #fff;
}

.req-material-search small {
  margin-left: auto;
  color: #8793a6;
  font-size: 9px;
  white-space: nowrap;
}

.req-material-search small b { color: #5148d8; }

.req-material-search + .req-edit-table {
  margin-top: 0;
  border-radius: 0 0 12px 12px;
}

@media (max-width: 700px) {
  .batch-picker-dialog {
    width: calc(100vw - 14px) !important;
    max-width: calc(100vw - 14px);
    max-height: calc(100dvh - 14px);
  }

  .batch-picker-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .batch-picker-search {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex-basis: 100%;
  }

  .batch-picker-toolbar > button { flex: 1; }
  .batch-picker-list { grid-template-columns: 1fr; padding: 10px; }

  .batch-picker-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .batch-picker-footer > div:last-child { display: grid; grid-template-columns: 1fr 1fr; }
  .direct-req-actions { width: 100%; }
  .direct-req-actions button { flex: 1; }
  .req-material-search { align-items: stretch; flex-wrap: wrap; }
  .req-material-search input { width: calc(100% - 28px); }
  .req-material-search small { width: 100%; margin-left: 28px; }
}

/* Production overview and viewport overflow correction */
body {
  max-width: 100vw;
  overflow-x: hidden;
}

.app-shell {
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
}

.app-shell > main,
.page,
.page > section {
  max-width: 100%;
}

.app-shell > main {
  overflow-x: clip;
}

.production-page-head .business-page-icon {
  border: 1px solid #deddfd;
  background: linear-gradient(145deg, #eeedff, #f5f4ff) !important;
  color: #5147d8 !important;
}

.production-page-head h3 {
  color: #17243a !important;
}

.production-page-head p {
  color: #68768c !important;
}

.production-page-head .business-page-note {
  min-width: 210px;
  padding: 11px 14px;
  border: 1px solid #e2e1fb;
  border-radius: 11px;
  background: #f7f7ff;
}

.production-page-head .business-page-note span {
  color: #453dbd !important;
  font-size: 11px;
}

.production-page-head .business-page-note small {
  margin-top: 3px;
  color: #7b879a !important;
}

.production-module-grid {
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.production-module-grid > button {
  position: relative;
  min-width: 0;
  min-height: 108px;
  padding: 16px 17px;
  overflow: hidden;
  border-color: #dfe5ef;
  border-radius: 15px;
  box-shadow: 0 8px 24px rgba(30, 47, 77, .05);
}

.production-module-grid > button::after {
  position: absolute;
  top: -28px;
  right: -28px;
  width: 74px;
  height: 74px;
  border: 13px solid rgba(81, 71, 229, .035);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.production-module-grid > button:hover {
  border-color: #cfcdf8;
  background: #fdfdff;
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(40, 51, 90, .09);
}

.production-module-grid > button i {
  width: 46px;
  height: 46px;
  border-radius: 13px;
}

.production-module-grid > button strong {
  color: #22324b;
  font-size: 14px;
}

.production-module-grid > button small {
  margin-top: 5px;
  color: #7d899c;
  font-size: 10px;
}

.production-module-grid > button b {
  position: relative;
  z-index: 1;
  padding: 6px 0 6px 8px;
  color: #5147dd;
}

@media (max-width: 700px) {
  .production-page-head .business-page-note {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #e2e1fb;
  }

  .production-module-grid {
    grid-template-columns: 1fr;
  }
}

/* Compact table picker used by sales orders and direct requisitions */
.batch-picker-dialog {
  width: min(1120px, calc(100vw - 34px));
  max-width: min(1120px, calc(100vw - 34px));
}

.batch-picker-table-wrap {
  position: relative;
  min-height: 300px;
  flex: 1 1 auto;
  overflow: auto;
  background: #fff;
}

.batch-picker-table {
  width: 100%;
  min-width: 870px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.batch-picker-table th,
.batch-picker-table td {
  height: 52px;
  padding: 9px 13px;
  overflow: hidden;
  border-right: 1px solid #e7eaf0;
  border-bottom: 1px solid #e4e8ef;
  color: #38465b;
  font-size: 11px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-picker-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  height: 46px;
  background: #f8f9fc;
  color: #7d8796;
  font-weight: 600;
}

.batch-picker-table th:nth-child(1) { width: 54px; }
.batch-picker-table th:nth-child(2) { width: 150px; }
.batch-picker-table th:nth-child(3) { width: 180px; }
.batch-picker-table th:nth-child(4) { width: 125px; }
.batch-picker-table th:nth-child(5) { width: 235px; }
.batch-picker-table th:nth-child(6) { width: 95px; }
.batch-picker-table th:nth-child(7) { width: 150px; }

.batch-picker-table th button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.batch-picker-table th button i {
  color: #b3bbc8;
  font-size: 10px;
  font-style: normal;
}

.batch-picker-table th button.active,
.batch-picker-table th button.active i { color: #5148dc; }

.batch-picker-table tbody.batch-picker-list {
  display: table-row-group;
  min-height: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
}

.batch-picker-table tbody tr { transition: background .15s ease; }
.batch-picker-table tbody tr:hover { background: #fafaff; }
.batch-picker-table tbody tr.selected { background: #f3f2ff; }
.batch-picker-table tbody tr.selected td:first-child { box-shadow: inset 3px 0 #5a50e5; }
.batch-picker-table td strong { color: #243650; font-size: 11px; }
.batch-picker-table input[type="checkbox"] { width: 16px; height: 16px; accent-color: #554be1; }
.batch-picker-table .picker-check { text-align: center; }

.picker-type {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef0ff;
  color: #5349d7;
  font-size: 9px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-picker-table-wrap > .batch-picker-empty {
  min-height: 300px;
}

.batch-picker-pagination {
  display: grid;
  min-height: 58px;
  flex: 0 0 auto;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 15px;
  padding: 9px 16px;
  border-top: 1px solid #e4e8ef;
  background: #fff;
  color: #7a8698;
  font-size: 10px;
}

.batch-picker-pagination > div:first-child strong { color: #5148dc; font-size: 13px; }
.batch-picker-page-controls { display: flex; justify-content: flex-end; align-items: center; gap: 5px; }
.batch-picker-page-controls select { height: 34px; min-width: 90px; padding: 0 25px 0 9px; font-size: 10px; }
.batch-picker-page-controls button,
.batch-picker-page-controls span button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  margin: 0 2px;
  place-items: center;
  padding: 0;
  border: 1px solid #e0e4eb;
  border-radius: 7px;
  background: #fff;
  color: #68758a;
  cursor: pointer;
}

.batch-picker-page-controls button:hover:not(:disabled),
.batch-picker-page-controls span button.active {
  border-color: #6258e5;
  background: #5a50e3;
  color: #fff;
}

.batch-picker-page-controls button:disabled { opacity: .38; cursor: default; }
.batch-picker-page-controls span i { margin: 0 4px; color: #9aa4b3; font-style: normal; }

@media (max-width: 700px) {
  .batch-picker-dialog { width: calc(100vw - 12px) !important; max-width: calc(100vw - 12px); }
  .batch-picker-table-wrap { min-height: 260px; }
  .batch-picker-table tbody.batch-picker-list { display: table-row-group; padding: 0; }
  .batch-picker-pagination { grid-template-columns: 1fr auto; }
  .batch-picker-pagination > div:nth-child(2) { display: none; }
  .batch-picker-page-controls span { display: none; }
}

/* Sales order list: keep dense business data readable without vertical text. */
.order-list-panel .document-filter-bar {
  align-items: center;
  padding: 14px 18px;
}

.order-list-panel .document-search { max-width: 720px; }

.order-list-shell {
  border-top: 1px solid var(--ui-border);
  border-bottom: 1px solid var(--ui-border);
}

.order-list-table {
  width: 100%;
  min-width: 1375px !important;
  table-layout: fixed !important;
}

.order-list-table th:nth-child(1) { width: 220px; }
.order-list-table th:nth-child(2) { width: 100px; }
.order-list-table th:nth-child(3) { width: 150px; }
.order-list-table th:nth-child(4) { width: 175px; }
.order-list-table th:nth-child(5) { width: 145px; }
.order-list-table th:nth-child(6) { width: 125px; }
.order-list-table th:nth-child(7),
.order-list-table th:nth-child(8) { width: 82px; }
.order-list-table th:nth-child(9) { width: 296px; }

.order-list-table th,
.order-list-table td {
  overflow: hidden;
  padding: 16px 14px;
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: normal;
}

.order-list-table tbody tr { height: 88px; }

.order-number-cell,
.order-type-cell,
.order-customer-cell,
.order-date-cell,
.order-amount-cell { min-width: 0; }

.order-number-cell strong,
.order-type-cell strong,
.order-customer-cell strong,
.order-date-cell strong,
.order-amount-cell strong {
  display: block;
  overflow: hidden;
  color: #21334e;
  font-size: 11px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-number-cell strong { color: #123b68; }

.order-number-cell > span,
.order-type-cell > span,
.order-customer-cell > span,
.order-date-cell > span,
.order-amount-cell > span {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: #8a97aa;
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-owner-cell .owner-identity {
  width: 100%;
  min-width: 0;
}

.order-owner-cell .owner-identity > span { max-width: 110px; }

.order-state-cell {
  text-align: center;
  white-space: nowrap;
}

.order-action-cell { overflow: visible !important; }

.order-list-table .row-actions {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.order-list-table .row-actions button {
  width: 100%;
  min-width: 0;
  min-height: 31px;
  padding: 6px 8px;
}

@media (max-width: 1100px) {
  .order-list-panel .document-filter-bar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .order-list-panel .document-search {
    width: 100%;
    max-width: none;
    flex-basis: 100%;
  }
}
