:root {
  --bg: #f5f9ff;
  --surface: #ffffff;
  --surface-2: #eef5ff;
  --ink: #10243f;
  --muted: #6c7d91;
  --line: #dbe7f5;
  --accent: #2557a6;
  --accent-dark: #183f82;
  --accent-soft: #eaf1fb;
  --warning: #b7791f;
  --danger: #b42318;
  --ok: #2557a6;
  --shadow: 0 18px 45px rgba(37, 87, 166, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

img {
  max-width: 100%;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  background: #ffffff;
  color: var(--ink);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2557a6, #4b8fd8);
  color: white;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.nav button {
  min-height: 42px;
  color: #52657c;
  background: transparent;
  border-radius: 8px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.main {
  padding: 24px;
  display: grid;
  gap: 20px;
  align-content: start;
}

.topbar {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.page-title h2 {
  margin: 0;
  font-size: 24px;
}

.page-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
}

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

.search {
  min-width: min(100%, 360px);
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 12px;
  box-shadow: 0 8px 20px rgba(37, 87, 166, 0.04);
}

.button {
  min-height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
  box-shadow: 0 10px 22px rgba(37, 87, 166, 0.2);
}

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

.button.secondary {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--accent-dark);
  box-shadow: none;
}

.button.danger {
  background: var(--danger);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.product-showcase {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  display: grid;
  gap: 24px;
}

.product-category-line {
  display: flex;
  justify-content: center;
  gap: 34px;
  color: var(--muted);
  font-size: 14px;
}

.product-category-line button,
.product-subcategory-line button {
  min-height: 36px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  font-weight: 650;
}

.product-category-line button {
  font-size: 16px;
}

.product-category-line button.active,
.product-subcategory-line button.active {
  color: var(--accent);
  font-weight: 700;
}

.product-category-line button:hover,
.product-subcategory-line button:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.product-subcategory-line {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.product-subcategory-line button {
  border: 1px solid var(--line);
  background: #ffffff;
  font-size: 13px;
}

.product-subcategory-line button.active {
  border-color: #b9cdec;
  background: var(--accent-soft);
}

.category-manager {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 12px;
}

.product-grid {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.product-card {
  min-height: 430px;
  background: #ffffff;
  border: 1px solid #edf0f1;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(245px, 1fr) auto auto;
  box-shadow: 0 14px 32px rgba(37, 87, 166, 0.08);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 42px rgba(37, 87, 166, 0.14);
}

.product-image {
  position: relative;
  min-height: 245px;
  padding: 24px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffffff 0%, #f4f9ff 100%);
}

.product-image img {
  width: 100%;
  height: 220px;
  object-fit: contain;
}

.product-image-placeholder {
  width: 190px;
  height: 190px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5d8;
  color: #8b9aa1;
  font-weight: 800;
}

.stock-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid #b9cdec;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.sku {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.product-copy {
  padding: 4px 20px 16px;
  text-align: center;
}

.product-copy h3 {
  margin: 7px 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.product-copy p {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.product-copy p span {
  display: inline-block;
  padding: 0 7px;
  color: #a6b2b7;
}

.stock {
  text-align: right;
  min-width: 76px;
}

.stock strong {
  display: block;
  font-size: 20px;
}

.stock span {
  color: var(--muted);
  font-size: 12px;
}

.qty-row,
.product-actions {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  align-items: center;
}

.product-actions {
  min-height: 58px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.qty-row input,
.product-actions input {
  width: 96px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.summary-band {
  background: #ffffff;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
}

.metric {
  min-height: 96px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.panel-header {
  min-height: 58px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 {
  margin: 0;
  font-size: 16px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  background: #f6faff;
  font-size: 12px;
  text-transform: uppercase;
}

td input,
td select,
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
}

td input:focus,
td select:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.field input:focus,
.field textarea:focus,
.search:focus {
  outline: 2px solid #b9cdec;
  border-color: #7f9ed0;
}

textarea {
  resize: vertical;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.form-grid label.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
}

.form-grid label.checkline input {
  width: auto;
  min-height: auto;
}

.address-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.address-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(37, 87, 166, 0.06);
}

.address-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.address-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.address-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

td .button + .button {
  margin-left: 6px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(16, 36, 63, 0.32);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal {
  width: min(100%, 680px);
  max-height: min(90vh, 760px);
  overflow: auto;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(16, 36, 63, 0.22);
}

.confirm-order {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.address-options {
  display: grid;
  gap: 10px;
}

.address-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  background: #ffffff;
}

.address-option small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background: #ffffff;
}

.login-visual {
  padding: 48px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(120deg, rgba(20, 62, 126, 0.9), rgba(37, 87, 166, 0.72)),
    url("https://images.unsplash.com/photo-1581092335397-9583eb92d232?auto=format&fit=crop&w=1600&q=80") center / cover;
}

.login-visual h1 {
  margin: 0;
  max-width: 680px;
  font-size: 46px;
  line-height: 1.05;
}

.login-visual p {
  max-width: 540px;
  color: #eaf5ff;
  line-height: 1.6;
}

.login-panel {
  min-height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #f4f9ff 100%);
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-box {
  width: min(100%, 420px);
  display: grid;
  gap: 18px;
}

.login-box h2 {
  margin: 0;
  font-size: 24px;
}

.login-box form,
.order-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field textarea {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.notice {
  border-radius: 8px;
  padding: 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  line-height: 1.45;
}

.notice.error {
  background: #fff1f0;
  color: var(--danger);
}

.status {
  font-weight: 650;
}

.status.ok {
  color: var(--ok);
}

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

.status.cancelled {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 14px;
  }

  .nav {
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .sidebar-footer {
    display: none;
  }

  .summary-band {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .login-visual {
    min-height: 36vh;
  }

  .login-panel {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .toolbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .address-actions,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .product-showcase {
    padding: 18px;
  }

  .product-category-line {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .product-subcategory-line {
    justify-content: flex-start;
  }

  .login-visual {
    padding: 28px;
  }

  .login-visual h1 {
    font-size: 34px;
  }
}
