:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #334155;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --ok: #22c55e;
  --err: #ef4444;
  --border: #475569;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Sarabun", "Noto Sans Thai", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #312e81 0%, transparent 60%),
              radial-gradient(900px 500px at -10% 110%, #1e3a8a 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 2.5rem 1rem 1.25rem;
}
header h1 { margin: 0; font-size: 2rem; letter-spacing: .3px; }
.subtitle { color: var(--muted); margin: .5rem auto 0; max-width: 640px; line-height: 1.5; }

main {
  max-width: 880px;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  background: var(--panel);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
  outline: none;
}
.dropzone:hover, .dropzone:focus { border-color: var(--accent-2); background: #243349; }
.dropzone.drag { border-color: var(--accent); background: #2a3a5c; transform: scale(1.01); }
.dz-icon { font-size: 2.5rem; }
.dz-text { margin: .6rem 0 .25rem; font-size: 1.05rem; }
.dz-link { color: var(--accent-2); text-decoration: underline; }
.dz-hint { color: var(--muted); font-size: .85rem; margin: 0; }

.file-info {
  display: flex; align-items: center; gap: .75rem;
  background: var(--panel-2); border-radius: 12px; padding: .75rem 1rem;
}
.file-info .fname { font-weight: 600; }
.file-info .fmeta { color: var(--muted); font-size: .85rem; margin-left: auto; }
.file-info .remove { cursor: pointer; color: var(--err); font-weight: 700; }

.btn {
  appearance: none; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 1rem; font-weight: 700;
  padding: .85rem 1.5rem; border-radius: 12px;
  transition: transform .05s, opacity .15s, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.status {
  border-radius: 12px; padding: .9rem 1.1rem;
  background: var(--panel-2); border: 1px solid var(--border);
  display: flex; align-items: center; gap: .6rem;
}
.status.busy::before { content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--muted); border-top-color: transparent; animation: spin .7s linear infinite; }
.status.err { border-color: var(--err); color: #fecaca; }
.status.ok { border-color: var(--ok); color: #bbf7d0; }
@keyframes spin { to { transform: rotate(360deg); } }

.result { display: flex; flex-direction: column; gap: 1rem; }

.receipt-header {
  background: var(--panel); border-radius: 14px; padding: 1rem 1.25rem;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem;
}
.receipt-header .field { display: flex; flex-direction: column; }
.receipt-header .label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.receipt-header .value { font-size: 1rem; font-weight: 600; }

.table-wrap { overflow-x: auto; background: var(--panel); border-radius: 14px; padding: .5rem; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: .7rem .85rem; text-align: left; }
thead th {
  color: var(--muted); font-weight: 600; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
tbody tr:nth-child(even) { background: #243349; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; border-top: 1px solid var(--border); }
tfoot .grand td { font-size: 1.1rem; color: var(--accent-2); }
.empty td { color: var(--muted); text-align: center; font-style: italic; }

.hidden { display: none !important; }

footer {
  text-align: center; padding: 1.5rem; color: var(--muted); font-size: .8rem;
}
#model-badge { display: inline-block; padding: .25rem .6rem; border: 1px solid var(--border);
  border-radius: 999px; }
