:root {
  color-scheme: light;
  --ink: #102235;
  --muted: #627488;
  --faint: #f3f8fd;
  --line: #d7e5f2;
  --panel: #ffffff;
  --sidebar: #063861;
  --sidebar-soft: #0e5f9d;
  --accent: #116db5;
  --accent-2: #23a9d1;
  --warn: #b66a00;
  --ok: #147a50;
  --shadow: 0 24px 70px rgba(8, 52, 90, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f3f8fd;
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 460px);
  justify-content: center;
  align-content: center;
  gap: 22px;
  padding: 32px;
  background:
    linear-gradient(140deg, #042f55 0%, #0b70b4 52%, #24acd5 100%),
    #063861;
}

.login-brand {
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0;
}

.brand-logo,
.avatar {
  display: inline-grid;
  place-items: center;
  font-weight: 800;
}

.brand-logo {
  width: min(430px, 92vw);
  height: 126px;
  margin-bottom: 18px;
  filter: drop-shadow(0 12px 24px rgba(0, 24, 48, 0.22));
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-brand .eyebrow,
.login-brand p {
  color: rgba(255, 255, 255, 0.78);
}

.login-brand h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.08;
}

.login-brand p:last-child {
  max-width: 420px;
  font-size: 16px;
  line-height: 1.65;
}

.login-panel {
  width: min(460px, 92vw);
  justify-self: center;
  margin: 0;
  padding: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.login-panel h2,
.topbar h1,
.data-section h2,
.pricing-workbench h2,
.dialog-header h2 {
  margin: 0;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  outline: none;
}

textarea {
  min-height: 128px;
  padding: 12px 14px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 109, 181, 0.14);
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: #a32929;
  font-size: 13px;
}

.primary-action,
.secondary-action,
.ghost-button,
.icon-button,
.danger-action {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  font-weight: 800;
}

.primary-action {
  color: #fff;
  background: var(--accent);
  padding: 0 18px;
}

.primary-action.compact {
  min-width: 116px;
}

.secondary-action,
.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
}

.danger-action {
  border: 1px solid #f0b9b9;
  background: #fff5f5;
  color: #b42318;
  padding: 0 14px;
}

.account-delete-button {
  margin-left: 8px;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
}

.logo {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}

.logo-image {
  width: 44px;
  height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.18));
}

.logo small,
.user-block small {
  display: block;
  color: rgba(255, 255, 255, 0.58);
}

.nav-stack {
  display: grid;
  gap: 8px;
  margin-top: 36px;
}

.nav-stack p {
  margin: 20px 4px 4px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 12px;
}

.nav-item {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  padding: 0 14px;
  text-align: left;
}

.nav-item.active {
  border-color: #65cef0;
  background: var(--sidebar-soft);
  color: #fff;
}

.user-block {
  margin-top: auto;
  display: grid;
  grid-template-columns: 40px 1fr 34px;
  gap: 10px;
  align-items: center;
}

.avatar {
  height: 40px;
  border-radius: 50%;
  background: #0e5f9d;
}

.user-block .icon-button {
  width: 34px;
  min-height: 34px;
  background: transparent;
  border-color: transparent;
  color: rgba(255, 255, 255, 0.7);
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-title-row,
.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.topbar {
  margin-bottom: 24px;
}

.topbar p,
.data-section p,
.pricing-workbench p,
.dialog-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.live-pill,
.rate-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 999px;
  background: #e5f5fb;
  color: #0a6991;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.todo-band,
.data-section,
.pricing-workbench {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(33, 22, 49, 0.05);
}

.todo-band {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  padding: 18px;
}

.todo-band strong,
.todo-band em {
  display: block;
}

.todo-band em {
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
}

.todo-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(105px, 1fr));
  gap: 10px;
}

.todo-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfafc;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.todo-button strong {
  margin-top: 6px;
  color: var(--accent);
  font-size: 22px;
}

.todo-button.active-todo {
  border-color: var(--accent);
  background: #eaf4fc;
  box-shadow: inset 0 0 0 1px rgba(18, 107, 168, 0.18);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 170px 210px 42px 130px;
  gap: 10px;
  margin: 16px 0;
}

.toolbar.slim {
  grid-template-columns: minmax(280px, 1fr) 190px 170px;
}

.partner-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  margin: 12px 0;
}

.partner-summary strong {
  color: var(--ink);
  font-size: 20px;
}

.partner-summary b,
.partner-summary em {
  border-left: 1px solid var(--line);
  padding-left: 14px;
  font-style: normal;
}

.order-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  align-items: start;
  gap: 14px;
}

.order-card {
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  text-align: left;
  box-shadow: 0 10px 28px rgba(33, 22, 49, 0.05);
}

.order-card.pending {
  border-left-color: var(--accent);
}

.order-card.done {
  border-left-color: var(--ok);
}

.card-head,
.metric-grid,
.meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.date-block {
  display: grid;
  color: var(--muted);
}

.date-block strong {
  color: var(--ink);
  font-size: 24px;
}

.badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  background: var(--faint);
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.dark {
  background: #063861;
  color: #fff;
}

.badge.ok {
  background: #e8f5ee;
  color: var(--ok);
}

.badge.warning-badge {
  background: #fff4e5;
  color: var(--warn);
}

.product-list {
  margin: 14px 0;
  display: grid;
  gap: 6px;
}

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

.metric-grid {
  align-items: stretch;
}

.metric {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fbfafc;
  padding: 10px;
}

.metric span,
.meta-line span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.metric.warning strong {
  color: var(--warn);
}

.next-step {
  margin: 14px 0;
  background: #eaf4fc;
  color: var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  font-weight: 800;
}

.muted-step,
.permission-note {
  background: #eef5fb;
  color: #4c657a;
}

.permission-note {
  margin-top: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  font-weight: 800;
}

.summary-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.pricing-workbench,
.data-section {
  padding: 18px;
  margin-bottom: 18px;
}

.supplier-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.supplier-strip article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfafc;
  display: grid;
  gap: 6px;
}

.supplier-strip span,
.supplier-strip em {
  color: var(--muted);
  font-style: normal;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  background: #e7f1fa;
  color: #33546f;
  font-size: 12px;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.quote-result {
  min-height: 44px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr)) 120px;
  gap: 12px;
  align-items: end;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfe;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.permission-grid article {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.permission-grid span {
  color: var(--muted);
  line-height: 1.55;
}

.order-dialog {
  width: min(970px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.small-dialog {
  width: min(560px, calc(100vw - 32px));
}

.order-dialog::backdrop {
  background: rgba(6, 56, 97, 0.62);
}

.dialog-polyfill-open {
  overflow: hidden;
}

.dialog-polyfill-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(6, 56, 97, 0.62);
}

.order-dialog.polyfill-open[open] {
  display: block;
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 901;
  max-height: calc(100vh - 48px);
  overflow: auto;
  transform: translate(-50%, -50%);
}

.dialog-header {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-body {
  padding: 20px;
}

.new-order-body {
  display: grid;
  gap: 18px;
}

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

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

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 20px 20px;
}

.detail-actions {
  margin-top: 12px;
}

.import-box,
.line-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfe;
  padding: 14px;
}

.import-box textarea {
  min-height: 96px;
  margin-top: 12px;
}

.line-editor {
  display: grid;
  gap: 12px;
}

.line-add-row {
  display: grid;
  grid-template-columns: 100px minmax(120px, 1fr) minmax(160px, 1.2fr) 72px 112px 112px 92px 86px;
  gap: 10px;
  align-items: center;
}

.compact-table table {
  min-width: 920px;
}

.inline-price-input {
  min-height: 36px;
  padding: 0 10px;
}

.warning-text {
  color: var(--warn);
  font-weight: 800;
}

.address-box,
.dialog-metrics {
  margin-top: 16px;
  border: 1px solid var(--line);
  background: #fbfafc;
}

.address-box {
  padding: 14px;
  line-height: 1.7;
}

.dialog-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.dialog-metrics div {
  padding: 14px;
  border-right: 1px solid var(--line);
}

.dialog-metrics div:last-child {
  border-right: 0;
}

@media (max-width: 1120px) {
  .order-grid {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }

  .todo-band,
  .todo-grid {
    grid-template-columns: 1fr;
  }
}

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

  .login-brand {
    min-height: 0;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-stack {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-stack p {
    grid-column: 1 / -1;
  }

  .content {
    padding: 18px;
  }

  .topbar,
  .section-title-row,
  .dialog-header,
  .topbar-actions {
    flex-direction: column;
  }

  .toolbar,
  .toolbar.slim,
  .order-grid,
  .supplier-strip,
  .admin-form,
  .permission-grid,
  .line-add-row,
  .form-grid,
  .dialog-metrics {
    grid-template-columns: 1fr;
  }
}
