* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Prompt", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(225, 29, 72, 0.16), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(14, 165, 233, 0.12), transparent 45%),
    #0b1220;
  color: #e8eef7;
}

.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 28px 20px;
  background: rgba(8, 13, 24, 0.92);
  border-right: 1px solid rgba(148, 163, 184, 0.14);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  color: inherit;
  text-decoration: none;
  border-radius: 14px;
  padding: 6px;
  margin-left: -6px;
  border: 1px solid transparent;
}

.brand.is-active {
  background: rgba(225, 29, 72, 0.14);
  border-color: rgba(225, 29, 72, 0.35);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #e11d48, #9f1239);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.05rem;
}

.brand small {
  color: #94a3b8;
  font-size: 0.78rem;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  color: #cbd5e1;
  text-decoration: none;
  border: 1px solid transparent;
}

.menu-item.is-active {
  background: rgba(225, 29, 72, 0.14);
  border-color: rgba(225, 29, 72, 0.35);
  color: #fff;
}

.menu-index {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e11d48;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.menu-section {
  margin-top: 24px;
}

.menu-section-title {
  margin: 0 0 4px 4px;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-section-desc {
  margin: 0 0 10px 4px;
  color: #94a3b8;
  font-size: 0.78rem;
  line-height: 1.45;
}

.menu-item span:last-child {
  line-height: 1.35;
}

.main {
  padding: 40px 48px 56px;
  position: relative;
  isolation: isolate;
  min-height: 100%;
}

/* โทน Config (Uploads Config + จัดการไฟล์) — ฟ้า/เทal */
.main--config {
  --tone-accent: #0284c7;
  --tone-accent-bright: #38bdf8;
  --tone-accent-soft: rgba(14, 165, 233, 0.14);
  --tone-accent-border: rgba(56, 189, 248, 0.34);
  --tone-glow-a: rgba(14, 165, 233, 0.2);
  --tone-glow-b: rgba(45, 212, 191, 0.12);
  box-shadow: inset 4px 0 0 0 var(--tone-accent);
  background:
    radial-gradient(920px 440px at 0% 0%, var(--tone-glow-a), transparent 58%),
    radial-gradient(720px 380px at 100% 6%, var(--tone-glow-b), transparent 52%),
    linear-gradient(180deg, rgba(7, 36, 58, 0.62) 0%, rgba(11, 18, 32, 0) 240px);
}

/* โทน Admin setup — ส้ม/อำพัน */
.main--admin {
  --tone-accent: #d97706;
  --tone-accent-bright: #fbbf24;
  --tone-accent-soft: rgba(245, 158, 11, 0.14);
  --tone-accent-border: rgba(251, 191, 36, 0.34);
  --tone-glow-a: rgba(245, 158, 11, 0.18);
  --tone-glow-b: rgba(167, 139, 250, 0.11);
  box-shadow: inset 4px 0 0 0 var(--tone-accent);
  background:
    radial-gradient(920px 440px at 0% 0%, var(--tone-glow-a), transparent 58%),
    radial-gradient(720px 380px at 100% 6%, var(--tone-glow-b), transparent 52%),
    linear-gradient(180deg, rgba(45, 28, 8, 0.55) 0%, rgba(11, 18, 32, 0) 240px);
}

.main--config .eyebrow {
  color: var(--tone-accent-bright);
}

.main--admin .eyebrow {
  color: #fcd34d;
}

.main--config .panel {
  border-color: var(--tone-accent-border);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(56, 189, 248, 0.08);
}

.main--admin .panel {
  border-color: var(--tone-accent-border);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(251, 191, 36, 0.08);
}

.main--config .field-label em {
  color: var(--tone-accent-bright);
}

.main--admin .field-label em {
  color: #fcd34d;
}

.main--config #site-id:focus,
.main--config #setup-version:focus {
  outline-color: var(--tone-accent);
  border-color: var(--tone-accent);
}

.main--admin #site-id:focus,
.main--admin #setup-version:focus {
  outline-color: var(--tone-accent);
  border-color: var(--tone-accent);
}

.main--config .field-checkbox input[type="checkbox"] {
  accent-color: var(--tone-accent);
}

.main--admin .field-checkbox input[type="checkbox"] {
  accent-color: var(--tone-accent);
}

.main--config .dropzone-icon {
  color: var(--tone-accent-bright);
}

.main--admin .dropzone-icon {
  color: var(--tone-accent-bright);
}

.main--config .dropzone.is-dragover {
  border-color: var(--tone-accent-bright);
  background: var(--tone-accent-soft);
}

.main--admin .dropzone.is-dragover {
  border-color: var(--tone-accent-bright);
  background: var(--tone-accent-soft);
}

.main--config .firmware-zip-option {
  border-color: var(--tone-accent-border);
  background: var(--tone-accent-soft);
}

.main--config .file-ready-summary,
.main--config .zip-preview strong {
  color: var(--tone-accent-bright);
}

.main--config .example-product {
  color: var(--tone-accent-bright);
}

.main--config .file-list code,
.main--admin .file-list code {
  color: inherit;
}

.main--config .file-row.is-ready code {
  color: #7dd3fc;
}

.main--admin .file-row.is-ready code {
  color: #fde68a;
}

.main--config .btn-primary {
  background: linear-gradient(180deg, #0ea5e9, #0369a1);
}

.main--admin .btn-primary {
  background: linear-gradient(180deg, #f59e0b, #b45309);
}

.main--config .config-table th {
  color: #7dd3fc;
}

.main--admin .admin-version-line strong {
  color: #fde68a;
}

.app:has(.main--config) .menu-item.is-active {
  background: rgba(14, 165, 233, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
}

.app:has(.main--config) .menu-item.is-active .menu-index {
  background: #0284c7;
}

.app:has(.main--admin) .menu-item.is-active {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(251, 191, 36, 0.35);
}

.app:has(.main--admin) .menu-item.is-active .menu-index {
  background: #d97706;
}

.page-head {
  max-width: 760px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #fb7185;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.lede {
  margin: 0;
  color: #94a3b8;
  line-height: 1.6;
}

.intro-head {
  max-width: 860px;
}

.intro-panel {
  max-width: 860px;
  margin-bottom: 24px;
}

.intro-title {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.intro-list {
  margin: 0;
  padding-left: 20px;
  color: #cbd5e1;
  line-height: 1.7;
}

.intro-list li + li {
  margin-top: 8px;
}

.intro-list code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: #fb7185;
}

.menu-guide {
  max-width: 860px;
}

.menu-guide-section + .menu-guide-section {
  margin-top: 24px;
}

.menu-guide-label {
  margin: 0 0 12px;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.menu-guide-grid {
  display: grid;
  gap: 10px;
}

.menu-guide-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.16);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.menu-guide-item:hover {
  border-color: rgba(225, 29, 72, 0.35);
  background: rgba(15, 23, 42, 0.92);
}

.menu-guide-index {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e11d48;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  flex-shrink: 0;
}

.menu-guide-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.menu-guide-body strong {
  font-size: 1rem;
  color: #f8fafc;
}

.menu-guide-body span {
  color: #94a3b8;
  font-size: 0.9rem;
  line-height: 1.55;
}

.panel {
  max-width: 760px;
  padding: 24px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.field,
.drop-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.field-label {
  font-weight: 600;
}

.field-label em {
  color: #fb7185;
  font-style: normal;
}

#site-id,
#setup-version,
.btn {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}

#site-id,
#setup-version {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #f8fafc;
  font: inherit;
  letter-spacing: 0.08em;
}

#site-id:focus,
#setup-version:focus {
  outline: 2px solid #e11d48;
  outline-offset: 1px;
  border-color: #e11d48;
}

.field-hint {
  color: #94a3b8;
  font-size: 0.85rem;
}

.field-hint--warn {
  color: #fbbf24;
}

.field-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.field-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: #e11d48;
  flex-shrink: 0;
}

.field-checkbox__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-checkbox__hint {
  margin-top: 0;
}

.field-checkbox--inset {
  margin-top: 16px;
}

.firmware-zip-option {
  margin: 8px 0 24px;
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid rgba(225, 29, 72, 0.35);
  background: rgba(225, 29, 72, 0.08);
}

.firmware-zip-option__title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 600;
}

.firmware-zip-option__check {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.firmware-zip-option__check input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.file-row--hosted.is-ready code {
  color: #86efac;
}

.field-error {
  color: #fda4af;
  font-size: 0.85rem;
}

.dropzone {
  min-height: 180px;
  padding: 28px 20px;
  border: 1.5px dashed #475569;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.7);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.is-dragover {
  border-color: #fb7185;
  background: rgba(225, 29, 72, 0.12);
}

.dropzone.has-files {
  border-color: #4ade80;
  border-style: solid;
  background: rgba(34, 197, 94, 0.1);
}

.dropzone.is-flash {
  animation: dropzone-flash 0.7s ease;
}

@keyframes dropzone-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.45);
  }
  100% {
    box-shadow: 0 0 0 16px rgba(74, 222, 128, 0);
  }
}

.dropzone-status {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #bbf7d0;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}

.dropzone-icon {
  color: #fb7185;
  margin-bottom: 8px;
}

.dropzone-title {
  margin: 0;
  font-weight: 600;
}

.dropzone-sub {
  margin: 6px 0 0;
  color: #94a3b8;
  font-size: 0.9rem;
}

.example-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.example-group {
  padding: 14px 16px 16px;
  border-radius: 14px;
  background: #0f172a;
  border: 1px solid #1e293b;
}

.example-product {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
  color: #fb7185;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 2px 0;
}

.file-row.has-existing code {
  color: #fbbf24;
}

.file-row.is-ready {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.28);
}

.file-row.is-ready code {
  color: #86efac;
}

.file-row.is-ready .file-status {
  color: #86efac;
  font-weight: 600;
}

.file-row--empty {
  justify-content: center;
  text-align: center;
}

.file-row--empty .file-status {
  color: var(--muted, #6b7280);
}

.file-row.is-pending .file-status {
  color: #64748b;
}

.file-ready-summary {
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.92em;
}

.file-meta {
  color: #94a3b8;
  font-size: 0.8rem;
  white-space: nowrap;
}

.firmware-source-path {
  margin: 0 0 6px;
  color: #e2e8f0;
}

.firmware-source-path code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: #fb7185;
}

.firmware-source-meta {
  margin: 0;
  color: #94a3b8;
  font-size: 0.85rem;
}

.admin-start-row {
  margin-bottom: 0;
}

.upload-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  margin-top: 20px;
}

.upload-panel[hidden] {
  display: none !important;
}

.admin-version-line {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid #1e293b;
  color: #cbd5e1;
  font-size: 0.9rem;
}

.admin-version-line strong {
  color: #fbbf24;
}

.file-row code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.95rem;
  color: #e2e8f0;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.zip-preview {
  margin: 0;
  color: #cbd5e1;
}

.btn-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.btn {
  height: 46px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost {
  background: transparent;
  border-color: #334155;
  color: #e2e8f0;
}

.btn-primary {
  background: #e11d48;
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
}

.btn-delete {
  height: 38px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
}

.config-table {
  width: 100%;
  border-collapse: collapse;
}

.config-table th,
.config-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #1e293b;
}

.config-table th {
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 600;
}

.config-table code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.95rem;
}

.cell-action {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: #94a3b8;
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  width: min(100%, 420px);
  padding: 24px;
  border-radius: 18px;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.modal-icon {
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.modal.is-info .modal-icon {
  background: rgba(14, 165, 233, 0.16);
  color: #7dd3fc;
}

.modal.is-success .modal-icon {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

.modal.is-error .modal-icon {
  background: rgba(244, 63, 94, 0.16);
  color: #fda4af;
}

.modal.is-confirm .modal-icon {
  background: rgba(225, 29, 72, 0.16);
  color: #fb7185;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.modal-message {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.6;
  white-space: pre-line;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.page-head--compact {
  margin-bottom: 16px;
}

.page-head--compact h1 {
  font-size: 1.55rem;
  line-height: 1.25;
}

.page-head--compact .lede {
  font-size: 0.92rem;
  line-height: 1.45;
}

.main--config .panel--config-upload {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 168px);
  padding-bottom: 0;
  overflow: hidden;
}

.panel--config-upload .panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
  scrollbar-gutter: stable;
}

.panel--config-upload .config-upload-top {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 4px;
}

.panel--config-upload .field,
.panel--config-upload .drop-block {
  margin-bottom: 12px;
}

.panel--config-upload .field--site-id {
  margin-bottom: 0;
}

.panel--config-upload .drop-block--inline {
  margin-bottom: 0;
}

.panel--config-upload .dropzone--compact {
  min-height: 118px;
  padding: 14px 12px;
}

.panel--config-upload .dropzone--compact .dropzone-icon {
  margin-bottom: 4px;
}

.panel--config-upload .dropzone--compact .dropzone-title {
  font-size: 0.95rem;
}

.panel--config-upload .dropzone--compact .dropzone-sub {
  font-size: 0.82rem;
  margin-top: 4px;
}

.panel--config-upload .dropzone-status {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.panel--config-upload .example-block--compact {
  gap: 6px;
  margin-bottom: 12px;
}

.panel--config-upload .example-group {
  padding: 10px 12px 12px;
}

.panel--config-upload .example-group--scroll {
  max-height: 132px;
  overflow-y: auto;
}

.panel--config-upload .file-row.is-ready {
  padding: 6px 8px;
}

.panel--config-upload .file-row--empty .file-status {
  font-size: 0.85rem;
}

.panel--config-upload .firmware-zip-option--compact {
  margin: 0 0 8px;
  padding: 12px 14px;
}

.panel--config-upload .firmware-zip-option--drop.is-dragover {
  border-color: var(--tone-accent-bright);
  background: var(--tone-accent-soft);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.panel--config-upload .firmware-zip-option__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel--config-upload .firmware-zip-option__title {
  margin: 0;
  font-size: 0.95rem;
}

.panel--config-upload .admin-version-line--inline {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.82rem;
  white-space: nowrap;
}

.panel--config-upload .file-list--single {
  margin-bottom: 8px;
}

.panel--config-upload .firmware-zip-option__check {
  margin-top: 0;
  padding-top: 10px;
}

.panel--config-upload .actions--form-footer {
  flex-shrink: 0;
  margin: 0 -24px;
  padding: 12px 24px 16px;
  background: rgba(15, 23, 42, 0.96);
  border-top: 1px solid rgba(56, 189, 248, 0.28);
  backdrop-filter: blur(8px);
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  }

  .main {
    padding: 24px 16px 40px;
  }

  .main--config .panel--config-upload {
    max-height: none;
  }

  .panel--config-upload .actions--form-footer {
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }
}
