:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #687385;
  --line: #dde3ea;
  --primary: #176b87;
  --primary-dark: #0f5268;
  --accent: #d9822b;
  --danger: #b42318;
  --shadow: 0 18px 60px rgba(27, 39, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(120deg, rgba(23, 107, 135, 0.88), rgba(23, 32, 42, 0.86)),
    url("https://images.unsplash.com/photo-1581091226033-d5c48150dbaa?auto=format&fit=crop&w=1800&q=80") center / cover;
}

.login-panel {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.login-panel h1,
.page-header h1,
.sidebar h2,
dialog h2 {
  margin: 0;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.primary,
.secondary,
.ghost,
.danger,
.nav-item,
.demo-accounts button,
.icon-btn {
  border: 0;
  border-radius: 6px;
  min-height: 38px;
  padding: 9px 14px;
  font-weight: 800;
}

.primary {
  background: var(--primary);
  color: white;
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  background: #e8eef3;
  color: #263544;
}

.ghost {
  background: transparent;
  color: var(--primary);
  padding-inline: 0;
}

.danger {
  background: #fce8e6;
  color: var(--danger);
}

.demo-accounts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.demo-accounts button {
  min-height: 30px;
  padding: 5px 10px;
  color: var(--primary);
  background: #e6f2f5;
}

.error {
  color: var(--danger);
  min-height: 20px;
  margin: 0;
}

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

.sidebar {
  background: #17202a;
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.sidebar .eyebrow {
  color: #f4b35e;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #ccd6df;
}

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

.account-card {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.account-card span {
  color: #aab7c3;
  font-size: 13px;
}

main {
  min-width: 0;
  padding: 28px;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  gap: 12px;
  margin-bottom: 18px;
}

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

.summary-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

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

.summary-grid strong {
  display: block;
  margin-top: 7px;
  font-size: 28px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1050px;
}

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

th {
  background: #f9fafb;
  color: #506070;
  font-size: 12px;
  text-transform: uppercase;
}

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

.order-detail-row td {
  background: #fff;
}

.order-detail-row td[rowspan] {
  background: #f9fafb;
  border-right: 1px solid var(--line);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #e8eef3;
  color: #263544;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag.good {
  background: #e7f6ed;
  color: #067647;
}

.tag.warn {
  background: #fff4df;
  color: #9a5b00;
}

.tag.bad {
  background: #fce8e6;
  color: var(--danger);
}

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

.inline-actions button {
  min-height: 31px;
  padding: 6px 10px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 18px;
}

.supplier-list {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.supplier-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.supplier-card-head > div:first-child {
  display: grid;
  gap: 6px;
}

.supplier-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.supplier-actions button {
  min-height: 32px;
  padding: 6px 11px;
}

.management-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
  margin-top: 20px;
}

.management-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.management-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.management-panel h2 {
  margin: 0;
  font-size: 20px;
}

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

.account-form button {
  grid-column: 1 / -1;
}

.compact-list {
  display: grid;
  gap: 10px;
}

.compact-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.compact-card > div:first-child {
  display: grid;
  gap: 4px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 6px;
  padding: 7px 12px;
  background: #e8eef3;
  color: #263544;
  font-weight: 800;
  text-decoration: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-card {
  padding: 22px;
}

.dialog-card header,
.dialog-card footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.dialog-card footer {
  grid-template-columns: auto 1fr auto auto;
  margin-top: 18px;
}

.icon-btn {
  width: 38px;
  padding: 0;
  background: #eef2f6;
  color: #263544;
  font-size: 24px;
  line-height: 1;
}

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

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

.events {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.event-row {
  display: grid;
  gap: 4px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: #344054;
  font-size: 13px;
}

.item-editor {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.item-editor-head,
.item-row {
  display: grid;
  align-items: end;
  gap: 10px;
}

.item-editor-head {
  grid-template-columns: 1fr auto;
}

.item-row {
  grid-template-columns: 1.2fr 1.2fr 0.9fr 0.7fr 0.7fr 0.8fr auto;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.item-row button {
  min-height: 40px;
}

.event-row small {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  background: #17202a;
  color: white;
  border-radius: 8px;
  padding: 13px 16px;
  box-shadow: var(--shadow);
}

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

  .sidebar {
    position: static;
  }

  .toolbar,
  .summary-grid,
  .inline-form,
  .form-grid,
  .supplier-card-head,
  .item-editor-head,
  .item-row,
  .management-grid,
  .account-form,
  .compact-card {
    grid-template-columns: 1fr;
  }

  .supplier-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    white-space: normal;
  }

  main {
    padding: 18px;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }
}
