: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-panel strong { font-size: 22px; }
.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;
}

.topbar strong { font-size: 20px; margin-right: 12px; }
.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; }
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: 24px; max-width: 1360px; margin: 0 auto; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 22px;
}

.hero > div:first-child {
  min-height: 220px;
  padding: 34px;
  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 12px; font-size: clamp(30px, 4vw, 54px); letter-spacing: 0; line-height: 1.05; }
.hero p { max-width: 780px; margin: 0; font-size: 18px; line-height: 1.6; }

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

.zalo-panel { padding: 18px; display: grid; gap: 12px; }
.result { min-height: 40px; color: var(--muted); white-space: pre-wrap; }

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

.content { display: grid; gap: 18px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.panel { padding: 16px; }
.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: 30px; font-weight: 720; margin-top: 6px; }
.muted { color: var(--muted); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #eef3f7; font-size: 13px; color: #42515e; }
tr:last-child td { border-bottom: 0; }

.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; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.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; }
  .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; }
}
