:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #687480;
  --line: #d8dee5;
  --soft: #f3f5f7;
  --paper: #fff;
  --red: #d92d28;
  --red-dark: #b8201c;
  --teal: #087f72;
  --navy: #182633;
  --shadow: 0 18px 48px rgba(23, 33, 43, 0.1);
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #edf0f3; font-size: 16px; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.dashboard-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px clamp(18px, 4vw, 56px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.brand img { width: 184px; max-height: 40px; object-fit: contain; object-position: left center; }
.brand span { display: grid; line-height: 1.08; }
.brand b { font-size: 0.95rem; }
.brand small { margin-top: 5px; color: var(--muted); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }
.dashboard-header nav { display: flex; align-items: center; gap: 9px; }
.account-pill { max-width: 220px; overflow: hidden; padding: 7px 11px; color: #43515e; background: #eef1f4; border-radius: 999px; font-size: 0.76rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
  transition: 0.18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(217, 45, 40, 0.2); outline-offset: 2px; }
.button-primary { color: #fff; background: var(--red); box-shadow: 0 8px 18px rgba(217, 45, 40, 0.2); }
.button-primary:hover { background: var(--red-dark); }
.button-light { color: var(--ink); background: #fff; border-color: var(--line); }
.button-small { min-height: 34px; padding: 6px 10px; font-size: 0.76rem; white-space: nowrap; }
.button-dark { color: #fff; background: var(--navy); }
.button-download { color: #08675d; background: #e4f4f0; border-color: #abd8ce; }
.button-disabled { color: #8c959d; background: #f3f4f5; border-color: #e1e4e7; pointer-events: none; }

main { width: min(1380px, calc(100% - 36px)); margin: 0 auto; padding: 34px 0 70px; }
.login-card { width: min(620px, 100%); margin: 7vh auto 0; padding: 36px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.login-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 14px; color: white; background: var(--navy); border-radius: 14px; font: 800 1.7rem/1 Arial, sans-serif; }
.eyebrow { margin: 0 0 7px; color: var(--red); font-size: 0.75rem; font-weight: 850; letter-spacing: 0.11em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 3.1rem); line-height: 1.08; letter-spacing: -0.035em; }
.login-card > p:not(.eyebrow) { max-width: 470px; margin: 12px auto 24px; color: var(--muted); line-height: 1.6; }
.login-card form { text-align: left; }
.login-card label, .filters label { display: grid; gap: 7px; color: #46515c; font-size: 0.8rem; font-weight: 800; }
.login-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #cfd5dc; border-radius: 7px; outline: none; }
.form-message { min-height: 22px; margin: 8px 0 0; color: var(--red-dark); font-size: 0.82rem; }
.login-card > small { display: block; margin-top: 12px; color: #88919a; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.hero p:last-child { margin: 8px 0 0; color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; margin-bottom: 18px; color: white; background: var(--navy); border-radius: 12px; box-shadow: var(--shadow); }
.metrics article { min-width: 0; padding: 19px 22px; border-right: 1px solid rgba(255,255,255,0.12); }
.metrics article:last-child { border-right: 0; }
.metrics span { display: block; font: 800 1.65rem/1 Arial, sans-serif; }
.metrics small { display: block; margin-top: 7px; color: #bcc6cf; }
.draft-workflow { display: flex; align-items: center; gap: 13px; margin-bottom: 18px; padding: 14px 17px; color: #654500; background: #fff5d9; border: 1px solid #ead49d; border-radius: 10px; }
.draft-workflow > span { flex: 0 0 auto; width: 32px; height: 32px; display: grid; place-items: center; color: white; background: #936000; border-radius: 50%; font-weight: 900; }
.draft-workflow strong, .draft-workflow small { display: block; }
.draft-workflow small { margin-top: 2px; color: #7a6740; }
.combine-workflow { display: grid; grid-template-columns: auto minmax(220px, 1fr) auto; align-items: center; gap: 15px; margin-bottom: 18px; padding: 15px 17px; color: #fff; background: linear-gradient(115deg, #182633, #24485d); border-radius: 11px; box-shadow: var(--shadow); }
.combine-workflow .select-all-control { display: flex; align-items: center; gap: 9px; min-width: 210px; color: #fff; font-size: 0.79rem; font-weight: 800; }
.combine-workflow input { width: 20px; min-height: 20px; accent-color: #d92d28; }
.combine-workflow strong, .combine-workflow small { display: block; }
.combine-workflow small { margin-top: 3px; color: #c6d3dc; }
.report-select { width: 19px; min-height: 19px; accent-color: var(--red); }
.select-column { width: 58px; text-align: center; }
.combined-row { background: #f7fbfd; }
.combined-badge { color: #245369 !important; background: #e3f0f5 !important; border-radius: 999px !important; padding: 3px 7px !important; font-weight: 850 !important; }

.list-card { overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 20px rgba(23,33,43,0.05); }
.list-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.list-heading h2 { margin: 0; font-size: 1.13rem; }
.list-heading p { margin: 3px 0 0; color: var(--muted); font-size: 0.82rem; }
.filters { display: grid; grid-template-columns: minmax(240px, 1fr) 180px 210px; gap: 10px; }
.filters input, .filters select { min-height: 40px; padding-block: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 1080px; border-collapse: collapse; }
th { padding: 11px 13px; color: #5b6670; text-align: left; white-space: nowrap; background: #f3f5f7; border-bottom: 1px solid var(--line); font-size: 0.74rem; }
td { padding: 13px; vertical-align: middle; border-bottom: 1px solid #e5e9ed; font-size: 0.85rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
.branch strong, .branch small { display: block; }
.branch strong { color: var(--ink); }
.branch small { margin-top: 3px; color: var(--muted); }
.muted { color: var(--muted); }
.count-line { display: flex; gap: 6px; white-space: nowrap; }
.count-line span { min-width: 30px; padding: 4px 6px; text-align: center; color: #53606c; background: #f1f3f5; border-radius: 5px; font: 750 0.74rem/1.2 Arial, sans-serif; }
.count-line .issue-count:not([data-zero="true"]) { color: #a11c18; background: #fde8e6; }
.status, .telegram-status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 20px; font-size: 0.73rem; font-weight: 800; white-space: nowrap; }
.status::before, .telegram-status::before { content: ""; width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
.status.complete { color: #08675d; background: #def2ed; }
.status.progress { color: #875800; background: #fff0c9; }
.status.ready { color: #08718a; background: #def2f6; }
.telegram-status.sent { color: #08675d; background: #def2ed; }
.telegram-status.failed { color: #a11c18; background: #fde8e6; }
.telegram-status.pending { color: #687480; background: #eef1f3; }
.progress-cell { min-width: 130px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 5px; color: var(--muted); font-size: 0.72rem; }
.progress-track { height: 6px; overflow: hidden; background: #e7ebee; border-radius: 8px; }
.progress-track i { display: block; height: 100%; background: var(--red); border-radius: inherit; }
.progress-track i.complete { background: var(--teal); }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.actions-heading { text-align: right; }
.empty-state { padding: 48px 24px; text-align: center; }
.empty-state strong, .empty-state span { display: block; }
.empty-state span { margin-top: 5px; color: var(--muted); }
.loading-row td { padding: 42px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; max-width: 360px; padding: 12px 16px; color: #fff; background: var(--navy); border-radius: 8px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 0.2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
[hidden] { display: none !important; }

@media (max-width: 760px) {
  .dashboard-header { align-items: flex-start; padding: 11px 14px; }
  .brand img { width: 136px; }
  .brand span { display: none; }
  .dashboard-header nav .button { min-height: 38px; padding: 7px 10px; font-size: 0.75rem; }
  .account-pill { display: none; }
  main { width: min(100% - 20px, 1380px); padding-top: 20px; }
  .login-card { margin-top: 3vh; padding: 24px 18px; }
  .login-row { grid-template-columns: 1fr; }
  .hero { align-items: flex-start; }
  .hero .button { padding-inline: 11px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics article:nth-child(2) { border-right: 0; }
  .metrics article:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,0.12); }
  .list-heading { align-items: stretch; flex-direction: column; padding: 18px; }
  .filters { grid-template-columns: 1fr; }
  .combine-workflow { grid-template-columns: 1fr; }
}
