:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5e6b76;
  --line: #d9e1e8;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --green: #1f8a5b;
  --yellow: #b7791f;
  --red: #c2413b;
  --blue: #2563a8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(10, 31, 52, .92), rgba(10, 31, 52, .62)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='420' viewBox='0 0 900 420'%3E%3Crect width='900' height='420' fill='%23698488'/%3E%3Cg fill='none' stroke='%23d9eff2' stroke-width='2' opacity='.42'%3E%3Cpath d='M0 290 C160 210 260 340 440 250 S720 180 900 260'/%3E%3Cpath d='M0 150 C180 80 330 220 510 130 S760 80 900 150'/%3E%3C/g%3E%3Cg fill='%23ffffff' opacity='.8'%3E%3Crect x='600' y='88' width='180' height='80' rx='6'/%3E%3Crect x='638' y='194' width='116' height='116' rx='58'/%3E%3Crect x='108' y='82' width='250' height='170' rx='8' opacity='.48'/%3E%3C/g%3E%3C/svg%3E") center / cover;
}

.login-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 14px;
  padding: 26px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(10, 31, 52, .18);
}

.login-logo { width: 280px; max-width: 100%; height: auto; display: block; margin-bottom: 2px; }
.login-panel h1 { color: var(--ink); font-size: 28px; margin: 0 0 4px; }
.login-panel label { display: grid; gap: 7px; color: var(--muted); }
.login-panel input { min-height: 40px; padding: 0 10px; }
.error { min-height: 20px; color: var(--red); font-weight: 650; }
.demo-accounts { color: var(--muted); font-size: 13px; line-height: 1.45; }

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 9px; box-shadow: 0 6px 16px rgba(11, 42, 74, .14); }
.topbar strong { font-size: 20px; margin-right: 4px; letter-spacing: .3px; }
.topbar span { color: var(--muted); }
.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--ink) !important;
  font-size: 13px;
  font-weight: 650;
}
.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.install-btn {
  border-color: #c8d7e5;
  background: #eef6fb;
  color: #12445d;
  font-weight: 650;
}
select, button, textarea, input {
  font: inherit;
}

select, textarea, input {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

select { min-height: 36px; padding: 0 10px; }
textarea { width: 100%; resize: vertical; padding: 10px; }

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button.primary, form button[type="submit"] {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.segmented button {
  border: 0;
  border-radius: 0;
  min-width: 74px;
}

.segmented button.active {
  background: var(--ink);
  color: #fff;
}

main { padding: 16px 24px 24px; max-width: 1440px; margin: 0 auto; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.hero > div:first-child {
  min-height: 132px;
  padding: 20px 22px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(10, 31, 52, .92), rgba(10, 31, 52, .58)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='420' viewBox='0 0 900 420'%3E%3Crect width='900' height='420' fill='%23698488'/%3E%3Cg fill='none' stroke='%23d9eff2' stroke-width='2' opacity='.42'%3E%3Cpath d='M0 290 C160 210 260 340 440 250 S720 180 900 260'/%3E%3Cpath d='M0 150 C180 80 330 220 510 130 S760 80 900 150'/%3E%3C/g%3E%3Cg fill='%23ffffff' opacity='.8'%3E%3Crect x='600' y='88' width='180' height='80' rx='6'/%3E%3Crect x='638' y='194' width='116' height='116' rx='58'/%3E%3Crect x='108' y='82' width='250' height='170' rx='8' opacity='.48'/%3E%3C/g%3E%3C/svg%3E") center / cover;
  border-radius: 8px;
}

h1 { margin: 0 0 10px; font-size: 30px; letter-spacing: 0; line-height: 1.12; }
.hero p { max-width: 860px; margin: 0; font-size: 14px; line-height: 1.5; }

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

.zalo-panel { padding: 14px; display: grid; gap: 10px; }
.zalo-panel textarea { min-height: 70px; max-height: 120px; }
.zalo-panel .result:empty { min-height: 0; }
.result { min-height: 40px; color: var(--muted); white-space: pre-wrap; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.tabs button.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.content { display: grid; gap: 14px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.panel { padding: 14px; }
.form-panel {
  display: grid;
  gap: 12px;
}

.form-panel h2 { margin: 0 0 2px; }
.form-panel label { display: grid; gap: 6px; color: var(--muted); }
.form-panel input, .form-panel select { min-height: 38px; padding: 0 10px; }
.metric { font-size: 26px; font-weight: 720; margin-top: 4px; }
.muted { color: var(--muted); }

.table-wrap { overflow: auto; }
.table-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 14px 0;
  font-weight: 750;
  color: #102033;
}
.small-text { font-size: 12px; line-height: 1.45; }
.review-note { font-weight: 500; }
.compact-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  margin-left: auto;
}
.review-table table { min-width: 1040px; }
.review-table td:nth-child(5) { max-width: 520px; line-height: 1.5; color: #42515e; }
.review-summary {
  cursor: pointer;
}
.review-summary:hover {
  background: #f7fbff;
}
.review-summary.expanded {
  background: #f3f8fc;
}
.review-detail td {
  background: #fbfdff;
}
.detail-title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 750;
  color: #657282;
}
.detail-lines {
  line-height: 1.55;
  color: #102033;
}
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #eef3f7; font-size: 13px; color: #42515e; }
tr:last-child td { border-bottom: 0; }
.customer-stock-table .customer-summary {
  cursor: pointer;
  background: #fff;
}
.customer-stock-table .customer-summary:hover {
  background: #f7fbff;
}
.customer-stock-table .customer-summary.expanded {
  background: #f3f8fc;
}
.icon-toggle {
  width: 28px;
  min-height: 28px;
  padding: 0;
  margin-right: 8px;
  border-radius: 999px;
  background: #eef3f7;
  color: #1c6e8c;
  border-color: #d8e3ec;
  font-weight: 800;
}
.stock-detail td {
  background: #fbfdff;
  color: #42515e;
}
.stock-detail td:nth-child(3) {
  padding-left: 28px;
  color: #102033;
}

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.normal { background: #e5f6ef; color: var(--green); }
.low { background: #fff4d8; color: var(--yellow); }
.out { background: #ffe7e5; color: var(--red); }
.draft { background: #e9f1ff; color: var(--blue); }
.confirmed { background: #e5f6ef; color: var(--green); }
.dispatched { background: #edf0f2; color: #43515d; }
.pending { background: #fff4d8; color: var(--yellow); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-action {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 280px;
}
.inline-action select { min-height: 34px; max-width: 190px; }
.secondary-btn {
  background: #eef3f7;
  color: #2f3c48;
  border-color: #d7e0e8;
}
.danger-btn {
  background: #fff1f0;
  color: var(--red);
  border-color: #ffc9c4;
}
.two-col { display: grid; grid-template-columns: minmax(320px, .78fr) minmax(420px, 1.22fr); gap: 14px; }
.doc-list li { margin-bottom: 8px; line-height: 1.45; }

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  main { padding: 16px; }
  .hero, .two-col { grid-template-columns: 1fr; }
  .hero > div:first-child { min-height: auto; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; min-width: 0; }
}
