/* =====================================================================
   AEorder — Design System
   ทิศทาง: ทางการ องค์กร / พื้นหลังขาวสะอาด / ฟ้าเป็นสี action
   ===================================================================== */
:root {
  /* palette */
  --ink:        #0f1f33;   /* ตัวอักษรหลัก น้ำเงินเข้มเกือบดำ */
  --ink-soft:   #4a5b70;
  --line:       #e3e8ef;   /* เส้นแบ่ง */
  --line-soft:  #f0f3f7;
  --paper:      #ffffff;
  --paper-2:    #f7f9fc;   /* พื้นรองอ่อนๆ */
  --blue:       #1d6fe0;   /* ฟ้าหลัก action */
  --blue-700:   #155bc1;
  --blue-50:    #eaf2fd;
  --green:      #1f9d5c;
  --amber:      #c9810b;
  --red:        #d23b3b;
  --shadow:     0 1px 2px rgba(15,31,51,.04), 0 4px 16px rgba(15,31,51,.06);

  --r:   10px;
  --r-sm: 7px;
  --font: "Inter", "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper-2);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
h1,h2,h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ---------- layout shell ---------- */
.topbar {
  height: 56px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 15px; letter-spacing: .02em;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--blue), var(--blue-700));
  color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
}
.brand-sub { color: var(--ink-soft); font-weight: 500; font-size: 12px; }
.topbar-spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-soft);
}
.user-chip b { color: var(--ink); font-weight: 600; }
.role-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--blue-50); color: var(--blue-700); font-weight: 600;
}

.shell { display: flex; min-height: calc(100vh - 56px); }
.side {
  width: 210px; background: var(--paper);
  border-right: 1px solid var(--line); padding: 14px 10px;
  flex-shrink: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--ink-soft); font-weight: 550; font-size: 13.5px;
  cursor: pointer; margin-bottom: 2px;
}
.nav-item:hover { background: var(--line-soft); color: var(--ink); }
.nav-item.active { background: var(--blue-50); color: var(--blue-700); }
.nav-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: #9aa7b8; padding: 14px 12px 6px; font-weight: 600;
}
.main { flex: 1; padding: 24px 28px; max-width: 1200px; }

/* ---------- page header ---------- */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; }
.page-head p { color: var(--ink-soft); margin: 4px 0 0; font-size: 13.5px; }

/* ---------- card ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--r-sm);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-700); }
.btn-ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper-2); border-color: #cfd8e3; }
.btn-danger { background: #fff; color: var(--red); border-color: #f3cccc; }
.btn-danger:hover { background: #fdf2f2; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }

/* ---------- table ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-weight: 600; color: var(--ink-soft);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); }
.tbl tr:hover td { background: var(--paper-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- status badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
}
.badge::before { content:""; width:6px; height:6px; border-radius:50%; background: currentColor; }
.b-draft     { background:#f0f3f7; color:#64748b; }
.b-submitted { background:#eaf2fd; color:#1d6fe0; }
.b-confirmed { background:#e9f7ef; color:#1f9d5c; }
.b-edited    { background:#fff6e6; color:#c9810b; }
.b-invoiced  { background:#eef0ff; color:#5560d8; }
.b-shipping  { background:#e6f6fb; color:#1296b8; }
.b-delivered { background:#e9f7ef; color:#1f9d5c; }
.b-cancelled { background:#fdeeee; color:#d23b3b; }

/* ---------- inputs ---------- */
.field { margin-bottom: 14px; }
.field label { display:block; font-size:12.5px; font-weight:600; color:var(--ink-soft); margin-bottom:6px; }
.input, select.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--r-sm); font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--paper);
}
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-50); }
.qty-input { width: 72px; text-align: right; }

/* ---------- stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 22px; }
.stat { background:var(--paper); border:1px solid var(--line); border-radius:var(--r); padding:16px 18px; box-shadow:var(--shadow); }
.stat .k { font-size:12px; color:var(--ink-soft); font-weight:600; text-transform:uppercase; letter-spacing:.03em; }
.stat .v { font-size:26px; font-weight:700; margin-top:6px; font-variant-numeric:tabular-nums; }
.stat .v small { font-size:13px; color:var(--ink-soft); font-weight:500; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--paper-2); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background:var(--paper); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow); padding: 32px 30px; }
.login-card .brand { justify-content:center; margin-bottom:6px; font-size:18px; }
.login-card .sub { text-align:center; color:var(--ink-soft); font-size:13px; margin-bottom:24px; }
.login-card .btn { width:100%; justify-content:center; margin-top:6px; }
.login-err { background:#fdeeee; color:var(--red); font-size:13px; padding:9px 12px; border-radius:var(--r-sm); margin-bottom:14px; }

/* ---------- misc ---------- */
.empty { text-align:center; padding:48px 20px; color:var(--ink-soft); }
.empty .big { font-size:15px; font-weight:600; color:var(--ink); margin-bottom:4px; }
.toast { position:fixed; bottom:22px; right:22px; background:var(--ink); color:#fff; padding:12px 18px; border-radius:var(--r-sm); font-size:13.5px; box-shadow:0 8px 24px rgba(0,0,0,.18); z-index:100; }
.row { display:flex; gap:10px; align-items:center; }
.spacer { flex:1; }
.muted { color:var(--ink-soft); }
.hide { display:none !important; }

@media (max-width: 860px) {
  .side { display:none; }
  .stats { grid-template-columns: repeat(2,1fr); }
  .main { padding: 18px 14px; }
}
