:root {
  --ink: #10183f;
  --ink-2: #29355f;
  --muted: #66708f;
  --soft: #f4f7fb;
  --line: #dde6ef;
  --line-2: #edf1f6;
  --white: #ffffff;
  --teal: #5ba9ad;
  --teal-dark: #3f8f94;
  --purple: #8d4b91;
  --blue: #566a9e;
  --green-bg: #eaf7f2;
  --green: #1f7a53;
  --red-bg: #fff0ef;
  --red: #b13b35;
  --amber-bg: #fff6df;
  --amber: #986c0d;
  --shadow: 0 18px 40px rgba(20, 31, 68, 0.10);
  --radius-lg: 24px;
  --radius: 16px;
  --sidebar: 292px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(145deg, #eef4f8 0%, #f7f9fc 44%, #eef3f7 100%);
}

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

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 15% 15%, rgba(91,169,173,.18), transparent 32%),
    radial-gradient(circle at 85% 10%, rgba(141,75,145,.14), transparent 30%),
    linear-gradient(145deg, #eef4f8 0%, #ffffff 45%, #edf4f8 100%);
}

.login-card {
  width: min(1080px, 100%);
  min-height: 660px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  overflow: hidden;
  border-radius: 32px;
  border: 1px solid rgba(221,230,239,.9);
  background: var(--white);
  box-shadow: var(--shadow);
}

.login-brand {
  padding: 58px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(160deg, #ffffff 0%, #eff7f7 100%);
  position: relative;
  overflow: hidden;
}

.login-brand:after {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -90px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(91,169,173,.18);
}

.logo-wrap img {
  width: 264px;
  max-width: 100%;
  display: block;
}

.login-brand h1 {
  font-size: clamp(38px, 5vw, 64px);
  line-height: .98;
  letter-spacing: -.05em;
  margin: 44px 0 18px;
}

.login-brand p {
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 520px;
}

.login-brand-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 44px;
}

.login-feature {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.74);
  padding: 16px;
}

.login-feature strong { display: block; margin-bottom: 6px; }
.login-feature span { color: var(--muted); font-size: 14px; }

.login-panel {
  padding: 58px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
}

.login-panel h2 {
  margin: 0 0 10px;
  font-size: 34px;
  letter-spacing: -.03em;
}

.login-panel > p { margin: 0 0 32px; color: var(--muted); line-height: 1.55; }

.form-stack { display: grid; gap: 18px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-2);
  margin-bottom: 8px;
}

.input, input[type="file"], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 13px 14px;
  color: var(--ink);
  outline: none;
  transition: border .18s ease, box-shadow .18s ease;
}

.input:focus, select:focus, textarea:focus {
  border-color: rgba(91,169,173,.75);
  box-shadow: 0 0 0 4px rgba(91,169,173,.13);
}

.password-row { position: relative; }
.password-row .ghost-mini {
  position: absolute;
  right: 8px;
  top: 8px;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 850;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 10px 22px rgba(16,24,63,.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.secondary { background: var(--teal-dark); }
.btn.purple { background: var(--purple); }
.btn.light {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.danger { background: #b13b35; }
.btn.full { width: 100%; }

.ghost-mini, .icon-btn {
  background: #f6f9fb;
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: 11px;
  padding: 8px 10px;
  font-weight: 800;
  font-size: 12px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  z-index: 5;
}

.sidebar-logo {
  padding: 8px 10px 22px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 18px;
}
.sidebar-logo img { width: 188px; display: block; }

.sidebar-group-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .11em;
  font-weight: 900;
  margin: 12px 12px 8px;
}

.nav { display: grid; gap: 6px; }
.nav button {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  border-radius: 13px;
  padding: 12px 12px;
  font-weight: 850;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav button:hover { background: #f4f8fb; border-color: var(--line-2); }
.nav button.active {
  background: #e8f5f5;
  border-color: rgba(91,169,173,.35);
  color: var(--ink);
}
.nav .nav-icon { width: 22px; text-align: center; }

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line-2);
}
.user-chip {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--teal), var(--purple));
}
.user-chip strong { display: block; font-size: 13px; }
.user-chip span { display: block; color: var(--muted); font-size: 12px; }

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 84px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
}
.mobile-menu { display: none; }
.page-title h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -.04em;
}
.page-title p { margin: 5px 0 0; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-box {
  min-width: 270px;
  position: relative;
}
.search-box input { padding-left: 40px; }
.search-box:before {
  content: "⌕";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 20px;
  z-index: 1;
}
.content { padding: 28px; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-split { grid-template-columns: 1.35fr .65fr; align-items: start; }

.card {
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 34px rgba(20,31,68,.06);
  overflow: hidden;
}
.card.pad { padding: 22px; }
.card-header {
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line-2);
}
.card-header h2, .card-header h3 { margin: 0; letter-spacing: -.02em; }
.card-header p { margin: 5px 0 0; color: var(--muted); }

.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 145px;
  box-shadow: 0 14px 28px rgba(20,31,68,.055);
}
.metric-top { display: flex; align-items: center; justify-content: space-between; }
.metric-title { color: var(--muted); font-weight: 800; font-size: 13px; }
.metric-icon {
  width: 42px; height: 42px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: #edf8f8;
}
.metric-value { font-size: 34px; font-weight: 950; letter-spacing: -.04em; }
.metric-foot { color: var(--muted); font-size: 13px; line-height: 1.4; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 950; background: #fbfdff; }
td { color: var(--ink-2); }
tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.status.green { background: var(--green-bg); color: var(--green); }
.status.red { background: var(--red-bg); color: var(--red); }
.status.amber { background: var(--amber-bg); color: var(--amber); }
.status.blue { background: #eef4ff; color: #3658a8; }
.status.grey { background: #eef1f5; color: #59657a; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.kpi {
  background: #f8fbfd;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 14px;
}
.kpi strong { display: block; font-size: 22px; letter-spacing: -.03em; }
.kpi span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }

.action-grid { display: grid; gap: 12px; }
.action-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 18px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.action-card:hover { border-color: rgba(91,169,173,.5); box-shadow: 0 10px 20px rgba(20,31,68,.06); }
.action-card strong { display: block; margin-bottom: 4px; }
.action-card span { color: var(--muted); font-size: 13px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 13px;
  background: #fff;
  color: var(--ink-2);
  font-weight: 850;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.product-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  display: grid;
  gap: 14px;
}
.product-image {
  height: 112px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 28%, rgba(255,255,255,.9), transparent 28%),
    linear-gradient(135deg, rgba(91,169,173,.2), rgba(86,106,158,.2));
  display: grid;
  place-items: center;
  font-size: 44px;
}
.product-card h3 { margin: 0; }
.product-meta { color: var(--muted); font-size: 13px; line-height: 1.45; }
.price-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.price { font-size: 22px; font-weight: 950; }
.qty-control { display: flex; align-items: center; gap: 7px; }
.qty-control button {
  width: 34px; height: 34px; border-radius: 11px;
  border: 1px solid var(--line);
  background: #f7fafc;
  font-weight: 950;
}
.qty-control input {
  width: 52px;
  text-align: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.cart-panel {
  position: sticky;
  top: 108px;
}
.cart-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
}
.cart-line:last-child { border-bottom: none; }
.cart-line strong { display: block; }
.cart-line span { color: var(--muted); font-size: 13px; }
.total-row {
  display: flex;
  justify-content: space-between;
  padding: 11px 0;
  color: var(--ink-2);
}
.total-row.grand { font-size: 22px; font-weight: 950; color: var(--ink); border-top: 1px solid var(--line); margin-top: 6px; padding-top: 16px; }
.payment-buttons { display: grid; gap: 10px; margin-top: 18px; }

.upload-box {
  border: 2px dashed rgba(91,169,173,.45);
  border-radius: 22px;
  padding: 28px;
  background: #f7fbfc;
  display: grid;
  gap: 16px;
  justify-items: start;
}
.upload-box h3 { margin: 0; }
.upload-box p { margin: 0; color: var(--muted); }
.mapping-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.progress {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef2f5;
}
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--purple)); width: 0%; transition: width .4s ease; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.integration-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.integration-card h3 { margin: 0 0 5px; }
.integration-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.switch {
  width: 54px;
  height: 30px;
  border-radius: 999px;
  border: none;
  background: #dfe5ec;
  padding: 3px;
  flex: 0 0 auto;
}
.switch:before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
  transition: transform .18s ease;
}
.switch.on { background: var(--teal); }
.switch.on:before { transform: translateX(24px); }

.timeline { display: grid; gap: 14px; }
.timeline-item { display: grid; grid-template-columns: 28px 1fr; gap: 11px; }
.dot { width: 13px; height: 13px; margin-top: 5px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 6px rgba(91,169,173,.13); }
.timeline-item strong { display: block; }
.timeline-item span { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16,24,63,.38);
  z-index: 20;
  display: none;
  align-items: stretch;
  justify-content: flex-end;
}
.drawer-backdrop.show { display: flex; }
.drawer {
  width: min(520px, 100%);
  background: #fff;
  box-shadow: -18px 0 40px rgba(12,17,45,.18);
  padding: 24px;
  overflow-y: auto;
}
.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.drawer-header h2 { margin: 0; }
.detail-stack { display: grid; gap: 14px; }
.detail-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 12px; border: 1px solid var(--line-2); border-radius: 14px; }
.detail-row span:first-child { color: var(--muted); font-weight: 800; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  background: var(--ink);
  color: #fff;
  padding: 14px 18px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  font-weight: 800;
}
.toast.show { opacity: 1; transform: translateY(0); }

.empty-state {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}
.empty-state strong { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }

@media (max-width: 1180px) {
  :root { --sidebar: 244px; }
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three, .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mapping-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .login-card { grid-template-columns: 1fr; }
  .login-brand, .login-panel { padding: 34px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-104%);
    transition: transform .2s ease;
    width: min(320px, 84vw);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-flex; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions, .search-box { width: 100%; }
  .search-box { min-width: 0; }
  .grid.two, .grid.three, .grid.four, .grid.main-split, .settings-grid, .kpi-row { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: 1fr; }
  .cart-panel { position: static; }
}

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .btn, .ghost-mini, .tab, .drawer-backdrop, .toast { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  .card, .metric-card { box-shadow: none; break-inside: avoid; }
}
