:root {
  color-scheme: light;
  font-family: "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  background: #f3f6f8;
  color: #182230;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #f3f6f8;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(20px, 5vw, 72px);
  background: #ffffff;
  border-bottom: 1px solid #dce3e8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 34px;
  height: 46px;
  object-fit: contain;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-copy strong {
  font-size: 19px;
  line-height: 1.25;
}

.brand-copy span {
  margin-top: 2px;
  color: #79858e;
  font-size: 10px;
  line-height: 1.2;
}

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

.docs-menu {
  position: relative;
  flex: 0 0 auto;
}

.docs-menu-button {
  white-space: nowrap;
}

.docs-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  display: none;
  width: 250px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid #dce3e8;
  border-radius: 10px;
  box-shadow: 0 16px 34px rgba(31, 48, 62, 0.16);
}

.docs-menu:hover .docs-menu-list,
.docs-menu:focus-within .docs-menu-list {
  display: grid;
  gap: 4px;
}

.docs-menu-list a {
  display: block;
  padding: 10px 12px;
  color: #263847;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
}

.docs-menu-list a:hover,
.docs-menu-list a:focus-visible {
  background: #eef7f8;
  color: #0b6871;
  outline: none;
}

.current-user {
  max-width: 180px;
  overflow: hidden;
  color: #576672;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button,
.secondary-button,
.danger-button,
.tab-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0;
}

.button {
  padding: 0 18px;
  background: #0f7c86;
  color: #ffffff;
}

.button:hover,
.button:focus-visible {
  background: #0b6871;
}

.secondary-button {
  padding: 0 14px;
  background: #ffffff;
  border-color: #cfd8df;
  color: #263847;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: #718492;
  background: #f7f9fa;
}

.danger-button {
  padding: 0 14px;
  background: #fff7f6;
  border-color: #e4b7b2;
  color: #9c3932;
}

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

.text-link {
  color: #285f7e;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.text-link:hover,
.text-link:focus-visible {
  text-decoration: underline;
}

.portal-main,
.admin-main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  flex: 1;
}

.portal-main {
  padding: 64px 0 54px;
}

.heading {
  max-width: 700px;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 9px;
  color: #5f6d78;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1.2;
}

.heading p:last-child {
  margin: 12px 0 0;
  color: #667581;
  font-size: 16px;
  line-height: 1.65;
}

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

.system-link {
  --accent: #0f7c86;
  --accent-soft: #e0f1f2;
  min-height: 232px;
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: #ffffff;
  border: 1px solid #d8e0e5;
  border-top: 4px solid var(--accent);
  border-radius: 6px;
  text-decoration: none;
  box-shadow: 0 10px 26px rgba(28, 41, 52, 0.06);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.system-link:hover,
.system-link:focus-visible {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 16px 34px rgba(28, 41, 52, 0.11);
  outline: none;
}

.system-link.leather {
  --accent: #8a5a35;
  --accent-soft: #f3e9df;
}

.system-link.cutting {
  --accent: #356fa0;
  --accent-soft: #e5eef6;
}

.system-link.quality {
  --accent: #a24c4c;
  --accent-soft: #f5e7e7;
}

.system-link.orders {
  --accent: #315f97;
  --accent-soft: #e5edf7;
}

.system-link.production-center {
  --accent: #7a5230;
  --accent-soft: #f2e9df;
}

.system-link.status-board {
  --accent: #5f7438;
  --accent-soft: #eaf0df;
}

.system-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.system-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  color: #4c5c67;
  background: #f6f8f9;
  border: 1px solid #d9e1e6;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2b986b;
  box-shadow: 0 0 0 3px #dff2e9;
}

.status-lan {
  color: #76501f;
  background: #fff8eb;
  border-color: #ead3aa;
}

.status-lan::before {
  background: #c98225;
  box-shadow: 0 0 0 3px #f7e6c9;
}

.system-copy {
  margin-top: 28px;
}

.system-copy h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.35;
}

.system-copy p {
  margin: 8px 0 0;
  color: #6b7883;
  font-size: 14px;
  line-height: 1.6;
}

.enter {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 22px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.arrow {
  width: 30px;
  height: 30px;
  position: relative;
  flex: 0 0 30px;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.arrow::before {
  content: "";
  width: 8px;
  height: 8px;
  position: absolute;
  top: 9px;
  left: 8px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
}

.empty-state,
.loading-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  padding: 28px;
  color: #6c7984;
  background: #ffffff;
  border: 1px dashed #c8d3db;
  border-radius: 6px;
  text-align: center;
}

.auth-main {
  width: min(420px, calc(100% - 32px));
  margin: 0 auto;
  flex: 1;
  display: grid;
  align-items: center;
  padding: 56px 0 72px;
}

.auth-panel {
  padding: 30px;
  background: #ffffff;
  border: 1px solid #d7e0e6;
  border-radius: 6px;
  box-shadow: 0 14px 34px rgba(29, 45, 58, 0.08);
}

.auth-panel h1 {
  font-size: 27px;
}

.auth-panel > p {
  margin: 8px 0 24px;
  color: #6a7883;
  font-size: 14px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.field > span,
.field-label {
  color: #40515e;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  background: #ffffff;
  border: 1px solid #cbd5dc;
  border-radius: 5px;
  color: #172533;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: #0f7c86;
  box-shadow: 0 0 0 3px rgba(15, 124, 134, 0.12);
}

.field input:disabled {
  background: #f1f4f6;
  color: #71808b;
}

.auth-panel .button {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
}

.message {
  display: none;
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 5px;
  font-size: 13px;
  line-height: 1.5;
}

.message.visible {
  display: block;
}

.message.error {
  background: #fff0ee;
  color: #9b342d;
}

.message.success {
  background: #e8f5ed;
  color: #27734f;
}

.admin-main {
  padding: 36px 0 54px;
}

.admin-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.admin-heading h1 {
  font-size: 30px;
}

.admin-heading p {
  margin: 7px 0 0;
  color: #697783;
  font-size: 14px;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: #e7edf1;
  border-radius: 6px;
}

.tab-button {
  flex: 0 0 auto;
  padding: 0 18px;
  background: transparent;
  color: #53636f;
}

.tab-button.active {
  background: #ffffff;
  color: #162636;
  box-shadow: 0 1px 4px rgba(26, 39, 50, 0.12);
}

.tab-panel[hidden] {
  display: none;
}

.panel {
  background: #ffffff;
  border: 1px solid #d7e0e6;
  border-radius: 6px;
}

.panel-head,
.admin-toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid #e1e7eb;
}

.panel-head h2,
.admin-toolbar h2 {
  margin: 0;
  font-size: 17px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(0, 1fr);
  gap: 16px;
}

.user-list {
  max-height: 680px;
  overflow: auto;
  padding: 6px;
}

.user-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #e7ecef;
  color: #1c2a37;
  cursor: pointer;
  text-align: left;
}

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

.user-row:hover,
.user-row.active {
  background: #edf6f7;
}

.user-row strong,
.user-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row small {
  display: block;
  margin-top: 4px;
  color: #75828c;
}

.badge {
  align-self: start;
  padding: 3px 7px;
  border-radius: 4px;
  background: #e6f3ed;
  color: #27734f;
  font-size: 11px;
  white-space: nowrap;
}

.badge.inactive,
.badge.failed {
  background: #fae9e7;
  color: #9a3a33;
}

.account-form {
  padding: 18px;
}

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

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  color: #324554;
  font-size: 14px;
}

.system-permissions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 20px;
}

.system-permissions.locked {
  opacity: 0.68;
}

.permission-option {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid #d7e0e6;
  border-radius: 5px;
  color: #344653;
  font-size: 13px;
}

.account-module-permissions {
  display: grid;
  gap: 10px;
  margin: 8px 0 20px;
}

.account-module-group {
  border: 1px solid #d7e0e6;
  border-radius: 5px;
  overflow: hidden;
}

.account-module-group h4 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid #e1e7eb;
  background: #f4f7f9;
  color: #273b49;
  font-size: 13px;
}

.account-module-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
  padding: 6px 12px;
}

.module-permission-option {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 0;
  color: #344653;
}

.module-permission-option input {
  margin-top: 3px;
}

.module-permission-option span,
.module-permission-option strong,
.module-permission-option small {
  min-width: 0;
  display: block;
}

.module-permission-option strong {
  font-size: 13px;
}

.module-permission-option small {
  margin-top: 3px;
  color: #74828d;
  font-size: 11px;
  line-height: 1.45;
}

.scope-note,
.panel-meta {
  color: #74828d;
  font-size: 12px;
}

.scope-note {
  margin: -10px 0 18px;
}

.access-layout {
  display: grid;
  gap: 16px;
}

.role-group + .role-group,
.module-group + .module-group {
  border-top: 1px solid #e1e7eb;
}

.group-heading {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 20px;
  padding: 16px;
  background: #f7f9fa;
}

.group-heading h3,
.module-group h3 {
  margin: 0;
  font-size: 15px;
}

.group-heading p {
  margin: 0;
  color: #687985;
  font-size: 12px;
  line-height: 1.6;
}

.role-summary-row {
  display: grid;
  grid-template-columns: minmax(170px, 230px) minmax(0, 1fr);
  gap: 18px;
  padding: 13px 16px;
  border-top: 1px solid #edf1f3;
}

.role-summary-row > div:first-child strong,
.role-summary-row > div:first-child span {
  display: block;
}

.role-summary-row > div:first-child strong {
  color: #243746;
  font-size: 13px;
}

.role-summary-row > div:first-child span {
  margin-top: 3px;
  color: #7a8790;
  font-size: 11px;
}

.permission-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.permission-tags span {
  padding: 4px 7px;
  border: 1px solid #d8e1e6;
  border-radius: 4px;
  background: #f6f8f9;
  color: #465966;
  font-size: 11px;
}

.module-group h3 {
  padding: 15px 16px 7px;
}

.module-table th:first-child,
.module-table td:first-child {
  min-width: 160px;
  font-weight: 700;
}

.module-table td:nth-child(2),
.module-table td:nth-child(3) {
  white-space: normal;
  line-height: 1.5;
}

.app-table {
  min-width: 1120px;
}

.warning-text {
  color: #a15b12;
  font-weight: 700;
}

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

.password-reset {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #e1e7eb;
}

.password-reset h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.password-actions input {
  min-width: 220px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cbd5dc;
  border-radius: 5px;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 11px 13px;
  border-bottom: 1px solid #e3e9ed;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #f4f7f9;
  color: #53636f;
  font-size: 12px;
  z-index: 1;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.device-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 22px 20px 26px;
  color: #75818b;
  font-size: 12px;
  border-top: 1px solid #dce3e8;
}

footer a {
  text-decoration: none;
}

footer a:hover,
footer a:focus-visible {
  color: #244f70;
  text-decoration: underline;
}

@media (max-width: 860px) {
  .portal-main {
    padding-top: 44px;
  }

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

  .system-link {
    min-height: 206px;
  }

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

  .user-list {
    max-height: 320px;
  }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 64px;
    gap: 12px;
    padding: 10px 14px;
  }

  .brand img {
    width: 26px;
    height: 36px;
  }

  .brand-copy strong {
    font-size: 16px;
  }

  .brand-copy span {
    display: none;
  }

  .current-user {
    display: none;
  }

  .topbar-actions {
    gap: 6px;
  }

  .docs-menu-list {
    right: -64px;
    width: min(260px, calc(100vw - 24px));
  }

  .topbar-actions .text-link {
    font-size: 13px;
    white-space: nowrap;
  }

  .topbar-actions .secondary-button {
    min-height: 36px;
    padding: 0 10px;
  }

  .portal-main,
  .admin-main {
    width: calc(100% - 28px);
  }

  .portal-main {
    padding: 34px 0 40px;
  }

  .heading {
    margin-bottom: 24px;
  }

  h1 {
    font-size: 29px;
  }

  .heading p:last-child {
    font-size: 15px;
  }

  .system-link {
    min-height: 194px;
    padding: 20px;
  }

  .system-copy {
    margin-top: 22px;
  }

  .auth-main {
    padding: 34px 0 48px;
  }

  .auth-panel {
    padding: 23px 20px;
  }

  .admin-main {
    padding: 24px 0 38px;
  }

  .admin-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-tabs {
    overflow-x: auto;
  }

  .tab-button {
    padding: 0 13px;
    white-space: nowrap;
  }

  .form-grid,
  .system-permissions,
  .account-module-options {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .admin-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .group-heading,
  .role-summary-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .password-actions input {
    width: 100%;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .system-link {
    transition: none;
  }
}
