* { box-sizing: border-box; }

:root {
  font-family: "Segoe UI", Tahoma, Arial, "Noto Sans Thai", sans-serif;
  color: #1d2939;
  background: #f5f7fb;
  font-synthesis: none;
  --navy: #0f172a;
  --navy-2: #172033;
  --blue: #2563eb;
  --blue-2: #1d4ed8;
  --blue-soft: #eff6ff;
  --border: #e4e7ec;
  --muted: #667085;
  --surface: #ffffff;
  --soft: #f8fafc;
  --green: #067647;
  --amber: #b54708;
  --red: #b42318;
  --shadow: 0 2px 10px rgba(16, 24, 40, .05);
}

html, body { min-height: 100%; }
body { margin: 0; background: #f5f7fb; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .62; }

.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 244px;
  padding: 24px 16px 18px;
  background: linear-gradient(180deg, #111c2d 0%, #0f172a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 20;
  box-shadow: 8px 0 28px rgba(15, 23, 42, .08);
}

.brand { display: flex; gap: 12px; align-items: center; padding: 2px 4px; margin-bottom: 30px; }
.brand-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #fff, #dbeafe);
  color: #0f172a; display: grid; place-items: center;
  font-weight: 800; letter-spacing: .5px; box-shadow: 0 5px 18px rgba(0,0,0,.18);
}
.brand-title { font-size: 18px; font-weight: 760; line-height: 1.2; }
.brand-sub { margin-top: 3px; font-size: 11px; color: #a9b5c6; }

.nav-label { padding: 0 12px 8px; font-size: 10px; letter-spacing: .12em; color: #718096; font-weight: 700; }
nav { display: grid; gap: 7px; }
.nav-btn {
  width: 100%; border: 0; text-align: left; display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 10px; background: transparent; color: #cbd5e1;
  transition: .18s ease;
}
.nav-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-btn.active { background: #25344c; color: #fff; box-shadow: inset 3px 0 0 #60a5fa; }
.nav-icon { width: 21px; text-align: center; font-size: 18px; }
.sidebar-spacer { flex: 1; }
.sidebar-status {
  display: flex; align-items: center; gap: 9px; margin: 0 4px 12px; padding: 11px;
  border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.04); border-radius: 10px;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.12); }
.sidebar-status-title { font-size: 12px; font-weight: 700; }
.sidebar-status-sub { margin-top: 2px; font-size: 10px; color: #94a3b8; }
.sidebar-note { padding: 0 5px; font-size: 10px; color: #64748b; }

.main { flex: 1; min-width: 0; margin-left: 244px; padding: 28px 32px 48px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 22px; margin-bottom: 24px; }
.eyebrow, .section-kicker { color: #2563eb; font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.topbar h1 { margin: 3px 0 3px; font-size: 28px; letter-spacing: -.02em; color: #101828; }
.topbar p { margin: 0; color: var(--muted); font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.today-chip { padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: #475467; font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.soft-card { background: linear-gradient(135deg, #ffffff 0%, #f7fbff 100%); }

.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(125px, 1fr)); gap: 11px; margin-bottom: 18px; }
.summary-card { position: relative; overflow: hidden; padding: 16px 16px 15px; min-height: 104px; }
.summary-card::after { content: ""; position: absolute; inset: auto -16px -34px auto; width: 78px; height: 78px; border-radius: 50%; background: currentColor; opacity: .05; }
.summary-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.summary-label { color: #667085; font-size: 12px; font-weight: 650; }
.summary-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #f2f4f7; font-size: 14px; }
.summary-value { margin-top: 11px; font-size: 29px; font-weight: 800; letter-spacing: -.03em; color: #101828; }
.summary-sub { margin-top: 2px; color: #98a2b3; font-size: 10px; }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 11px; margin-bottom: 22px; }
.search-wrap { flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid #d0d5dd; border-radius: 9px; background: #fff; }
.search-wrap:focus-within { border-color: #84adff; box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.search-icon { color: #98a2b3; font-size: 17px; }
.search-wrap input { width: 100%; border: 0; padding: 10px 0; outline: 0; }
.filter-select { min-width: 150px; }

input, select, textarea { border: 1px solid #d0d5dd; border-radius: 9px; padding: 10px 11px; background: #fff; color: #344054; outline: 0; }
input:focus, select:focus, textarea:focus { border-color: #84adff; box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
textarea { width: 100%; resize: vertical; line-height: 1.55; }

.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 11px; }
.section-head h2 { margin: 3px 0 0; font-size: 18px; color: #101828; }
.result-count { color: #667085; font-size: 12px; }

.btn { border: 1px solid #d0d5dd; border-radius: 9px; padding: 9px 12px; background: #fff; color: #344054; font-weight: 650; transition: .15s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 9px rgba(16,24,40,.06); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-2); }
.btn-secondary { background: #f8fafc; }
.btn-ghost { background: transparent; border-color: #e4e7ec; }
.btn-warning { background: #fff8eb; border-color: #fedf89; color: #b54708; }
.btn-success { background: #ecfdf3; border-color: #abefc6; color: #067647; }
.btn-danger { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.btn-large { padding: 11px 18px; }
.btn-icon-text { display: inline-flex; align-items: center; gap: 7px; }

.promotion-list { display: grid; gap: 12px; }
.promo-card { position: relative; padding: 17px 18px 16px; transition: .18s ease; }
.promo-card:hover { border-color: #d0d5dd; box-shadow: 0 5px 18px rgba(16,24,40,.07); }
.promo-head { display: flex; justify-content: space-between; gap: 16px; }
.promo-name { font-size: 17px; font-weight: 760; color: #101828; margin-bottom: 5px; }
.meta { color: #667085; font-size: 12px; line-height: 1.6; }
.meta-dot { margin: 0 6px; color: #d0d5dd; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-content: flex-start; }
.badge { padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.status-New { background: #eef4ff; color: #3538cd; }
.status-Setting, .status-Waiting-Test { background: #fffaeb; color: #b54708; }
.status-Ready { background: #eff8ff; color: #175cd3; }
.status-Active, .status-Completed { background: #ecfdf3; color: #067647; }
.status-On-Hold { background: #fff4e5; color: #b54708; }
.status-Cancelled { background: #fef3f2; color: #b42318; }
.priority-Normal { background: #f2f4f7; color: #475467; }
.priority-Urgent { background: #fff7e6; color: #b54708; }
.priority-Critical { background: #fef3f2; color: #b42318; }

.progress-line { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.progress-track { flex: 1; height: 8px; background: #eaecf0; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb); border-radius: 999px; transition: width .25s ease; }
.progress-number { min-width: 38px; text-align: right; font-size: 11px; color: #475467; font-weight: 750; }

.counts { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 8px; margin-top: 12px; }
.metric-chip { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; background: #f8fafc; border: 1px solid #f0f2f5; font-size: 12px; color: #475467; }
.metric-chip b { color: #101828; }
.card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; padding-top: 12px; border-top: 1px solid #f0f2f5; }

.page-intro { display: flex; align-items: center; gap: 14px; padding: 18px; margin-bottom: 14px; }
.intro-icon { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; background: #eff6ff; color: #2563eb; font-size: 24px; font-weight: 700; }
.page-intro h2 { margin: 0 0 3px; font-size: 18px; }
.page-intro p { margin: 0; color: #667085; font-size: 13px; }

.form-card { padding: 0; overflow: hidden; }
.form-section { padding: 22px; border-bottom: 1px solid #eef0f3; }
.form-section.no-border { border-bottom: 0; }
.form-section-head { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 17px; }
.form-section-head h3 { margin: 0 0 2px; font-size: 15px; color: #101828; }
.form-section-head p { margin: 0; font-size: 11px; color: #98a2b3; }
.form-title-wrap { display: flex; gap: 11px; align-items: flex-start; }
.step-badge { min-width: 32px; height: 32px; padding: 0 7px; display: grid; place-items: center; border-radius: 9px; background: #eff6ff; color: #2563eb; font-size: 11px; font-weight: 800; }
.section-row { justify-content: space-between; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label, .field-block { display: grid; gap: 6px; color: #344054; font-size: 12px; font-weight: 680; }
.form-grid input, .form-grid select { width: 100%; }
.field-block { margin-top: 14px; }

.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.channel-grid label, .branch-grid label { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid #e4e7ec; border-radius: 9px; background: #fbfcfd; font-size: 12px; transition: .15s ease; }
.channel-grid label:has(input:checked), .branch-grid label:has(input:checked) { border-color: #84adff; background: #f5f9ff; box-shadow: inset 0 0 0 1px #84adff; }
.channel-grid input, .branch-grid input { accent-color: #2563eb; }

.inline-actions { display: flex; gap: 6px; }
.branch-summary-line { display: flex; justify-content: flex-end; margin: -5px 0 8px; font-size: 11px; color: #667085; }
.branch-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; max-height: 285px; overflow: auto; padding: 10px; border: 1px solid #e4e7ec; border-radius: 10px; background: #fff; }

.table-wrap { overflow: auto; }
.bordered-table { border: 1px solid #e4e7ec; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 9px 10px; border-bottom: 1px solid #eef0f3; text-align: left; vertical-align: top; }
th { background: #f8fafc; color: #475467; font-size: 11px; font-weight: 750; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td input { min-width: 90px; width: 100%; padding: 8px 9px; }

.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 15px 22px; border-top: 1px solid #eef0f3; background: #fbfcfd; }
.loading-line { display: flex; gap: 9px; align-items: center; justify-content: flex-end; padding: 0 22px 15px; color: #175cd3; font-size: 12px; background: #fbfcfd; }
.spinner { width: 17px; height: 17px; border: 3px solid #bfdbfe; border-top-color: #2563eb; border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.back-button { margin-bottom: 12px; }
.detail-card { padding: 20px; }
.detail-hero { padding: 18px; margin-bottom: 12px; }
.detail-block { background: #f8fafc; border: 1px solid #e4e7ec; border-left: 4px solid #2563eb; padding: 14px 16px; border-radius: 9px; margin: 12px 0; line-height: 1.65; }
.detail-title { color: #101828; font-size: 13px; font-weight: 780; margin-bottom: 8px; }
.branch-checks { display: flex; gap: 9px; flex-wrap: wrap; }
.branch-checks label { white-space: nowrap; }
.branch-checks input { accent-color: #2563eb; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; background: #101828; color: white; padding: 11px 14px; border-radius: 9px; font-size: 12px; box-shadow: 0 12px 34px rgba(16,24,40,.22); }
.empty { padding: 40px; text-align: center; color: #667085; }

@media (max-width: 1180px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .branch-grid, .check-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 850px) {
  .sidebar { width: 72px; padding: 20px 10px; }
  .brand-copy, .nav-label, .nav-btn span:last-child, .sidebar-status div, .sidebar-note { display: none; }
  .brand { justify-content: center; }
  .nav-btn { justify-content: center; padding: 11px; }
  .nav-icon { width: auto; }
  .sidebar-status { justify-content: center; padding: 10px; }
  .main { margin-left: 72px; padding: 22px 18px 38px; }
}

@media (max-width: 680px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px 12px 32px; }
  .topbar { align-items: flex-start; }
  .today-chip { display: none; }
  .topbar h1 { font-size: 23px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .filter-select { width: 100%; }
  .form-grid, .branch-grid, .check-grid { grid-template-columns: 1fr; }
  .promo-head { flex-direction: column; }
  .badges { justify-content: flex-start; }
  .counts { grid-template-columns: 1fr; }
  .section-row { align-items: flex-start; flex-direction: column; }
  .inline-actions { width: 100%; }
  .inline-actions .btn { flex: 1; }
  .form-actions { position: sticky; bottom: 0; }
}
