:root {
  color-scheme: light;
  --app-ink: #172033;
  --app-muted: #64748b;
  --app-line: #e8edf5;
  --app-indigo: #4f46e5;
  --theme-primary: #4f46e5;
  --theme-primary-text: #fff;
  --theme-primary-hover: #4338ca;
  --theme-primary-soft: #e0e7ff;
  --theme-secondary: #0891b2;
  --theme-secondary-text: #fff;
  --theme-sidebar: #fff;
  --theme-sidebar-text: #172033;
  --theme-sidebar-muted: #64748b;
  --theme-background: #f6f8fc;
  --theme-card: #fff;
  --theme-text: #172033;
  --theme-card-text: #172033;
  --theme-muted: #64748b;
  --theme-card-muted: #64748b;
  --theme-line: #e8edf5;
}

html { scroll-behavior: smooth; }
body {
  background: #f6f8fc;
  color: var(--app-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:not(:disabled) { transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease; }
button:not(:disabled):active { transform: translateY(1px); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgb(99 102 241 / 24%);
  outline-offset: 2px;
}

#app > section {
  background:
    radial-gradient(ellipse at 20% 12%, rgb(199 210 254 / 45%), transparent 38%),
    radial-gradient(ellipse at 85% 90%, rgb(165 243 252 / 34%), transparent 34%),
    #f6f8fc;
}
#app > section > div {
  border-color: rgb(255 255 255 / 90%);
  box-shadow: 0 24px 70px rgb(30 41 59 / 12%);
}

.brand-mark { display: inline-flex; width: 2.75rem; height: 2.75rem; flex: 0 0 auto; }
.brand-mark.h-12.w-12 { width: 3rem; height: 3rem; }
.brand-mark.h-14.w-14 { width: 3.5rem; height: 3.5rem; }
.app-icon { display: inline-block; flex: 0 0 auto; vertical-align: middle; }
.brand-mark svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 5px 9px rgb(79 70 229 / 20%)); }
#app #realtime-indicator {
  position: fixed !important;
  inset: auto 1rem 1rem auto !important;
  z-index: 50 !important;
  max-width: calc(100vw - 2rem);
}
.nav-item { min-height: 2.75rem; }
.nav-item svg { flex: 0 0 auto; opacity: .85; }
.nav-item:hover { transform: translateX(2px); }
.dashboard-stat { position: relative; overflow: hidden; }
.dashboard-stat::after {
  position: absolute;
  right: -1.1rem;
  bottom: -1.75rem;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: rgb(99 102 241 / 4%);
  content: "";
  transition: transform 180ms ease;
}
.dashboard-stat:hover::after { transform: scale(1.5); }

.machine-filter-panel {
  display: flex;
  width: min(100%, 25rem);
  flex-direction: column;
  gap: .45rem;
  margin-bottom: 1rem;
  border: 1px solid var(--app-line);
  border-radius: 1rem;
  background: #fff;
  padding: .8rem .95rem;
  box-shadow: 0 2px 8px rgb(15 23 42 / 3%);
}
.machine-filter-panel > span {
  display: flex;
  align-items: center;
  gap: .45rem;
  color: #475569;
  font-size: .75rem;
  font-weight: 700;
}
.machine-filter-panel > span svg { color: #4f46e5; }
.machine-filter-panel select {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #172033;
  font-size: .9rem;
  font-weight: 650;
  outline: none;
}
.machine-filter-panel:focus-within { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgb(99 102 241 / 10%); }

.status-pill { box-shadow: inset 0 0 0 1px rgb(15 23 42 / 3%); }
.status-pill svg { flex: 0 0 auto; }
.status-repair-progress { border: 1px solid #fed7aa; background: #fff7ed; color: #9a3412; }
table thead { background: #f8fafc; }
table tbody tr { transition: background-color 140ms ease; }
table tbody tr:hover { background: #f8faff; }
table tbody td { vertical-align: middle; }

.action-button { display: inline-flex; align-items: center; justify-content: center; gap: .55rem; }
.action-button svg { flex: 0 0 auto; }
.upload-progress-panel {
  display: grid;
  gap: .65rem;
  border: 1px solid #dbeafe;
  border-radius: .95rem;
  background: linear-gradient(135deg, #f8fbff, #eff6ff);
  padding: .9rem 1rem;
}
.upload-progress-panel.hidden { display: none; }
.upload-progress-track {
  height: .65rem;
  overflow: hidden;
  border-radius: 999px;
  background: #dbeafe;
}
.upload-progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4f46e5, #0891b2);
  box-shadow: 0 0 12px rgb(79 70 229 / 25%);
  transition: width 180ms ease;
}
.upload-success { display: flex; align-items: center; gap: .4rem; color: #047857 !important; }
.upload-failed { border-color: #fecaca; background: #fff7f7; }
.upload-progress-floating {
  position: fixed;
  z-index: 60;
  right: 1rem;
  bottom: 4.5rem;
  width: min(28rem, calc(100vw - 2rem));
  box-shadow: 0 16px 40px rgb(15 23 42 / 18%);
}
.upload-field { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; gap: .55rem; }
.upload-file-bubble {
  position: relative;
  top: 4px;
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  overflow: hidden;
  border: 1px solid #4338ca;
  border-radius: 999px;
  background: linear-gradient(120deg, #4f46e5, #0891b2);
  padding: .4rem .75rem;
  color: #fff;
  font-size: .72rem;
  font-weight: 750;
  box-shadow: 0 3px 9px rgb(79 70 229 / 18%);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}
.upload-file-bubble:hover { top: 3px; transform: translateY(-1px); filter: saturate(1.12); box-shadow: 0 6px 14px rgb(79 70 229 / 24%); }
.upload-file-bubble:focus-within { outline: 3px solid rgb(99 102 241 / 25%); outline-offset: 2px; }
.upload-file-bubble > svg { flex: 0 0 auto; }
.upload-file-bubble > .app-icon { width: 14px !important; height: 14px !important; }
.upload-file-bubble > input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}
.upload-file-name { min-width: 0; overflow-wrap: anywhere; color: #64748b; font-size: .72rem; }

.calculator-workspace { max-width: 58rem; margin: 0 auto; }
.calculator-input-panel {
  border: 1px solid #e5e7eb;
  border-radius: 1.35rem;
  background: rgb(255 255 255 / 94%);
  padding: 1.1rem;
  box-shadow: 0 12px 32px rgb(30 41 59 / 7%);
}
.calculator-heading-icon {
  display: inline-flex;
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: linear-gradient(135deg, #e0e7ff, #cffafe);
  color: #4338ca;
}
.calculator-price-card {
  border: 1px solid #e8edf5;
  border-radius: 1.25rem;
  background: #fff;
  padding: 1.2rem;
  box-shadow: 0 8px 24px rgb(30 41 59 / 6%);
}
.calculator-user-card { border-top: 3px solid #6366f1; }
.calculator-member-card { border-top: 3px solid #10b981; }
.calculator-price-tag {
  border-radius: 999px;
  background: #f1f5f9;
  padding: .3rem .6rem;
  color: #475569;
  font-size: .68rem;
  font-weight: 750;
}
.calculator-member-card .calculator-price-tag { background: #d1fae5; color: #047857; }
.calculator-savings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-radius: 1.2rem;
  background: linear-gradient(115deg, #047857, #059669);
  padding: 1.1rem 1.25rem;
  color: #fff;
  box-shadow: 0 12px 26px rgb(5 150 105 / 18%);
}
.calculator-savings strong { font-size: clamp(1.15rem, 4vw, 1.65rem); white-space: nowrap; }

.monitor-page .monitor-header {
  background: linear-gradient(115deg, #161c35, #312e81 65%, #155e75);
  box-shadow: 0 16px 36px rgb(30 41 59 / 18%);
}
.monitor-page .monitor-header .brand-mark svg { filter: drop-shadow(0 6px 13px rgb(15 23 42 / 35%)); }
.monitor-page .monitor-search-controls button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.monitor-page .monitor-search-controls button:hover { transform: translateY(-1px); }
.monitor-page .monitor-page,
.monitor-page .machine-filter-panel { position: relative; z-index: 1; }

@media (max-width: 640px) {
  .machine-filter-panel { width: 100%; }
  .monitor-page .monitor-header { align-items: flex-start; }
  .monitor-page .monitor-header > div:first-child { min-width: 0; }
  .monitor-page .monitor-header h1 { font-size: 1.35rem; }
  .monitor-page .monitor-header > div:last-child { width: 100%; justify-content: space-between; }
  .monitor-page .monitor-search-controls { flex-wrap: wrap; }
  .monitor-page .monitor-search-controls input { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

body { background: var(--theme-background); color: var(--theme-text); }
#app > div { background: var(--theme-background); color: var(--theme-text); }
#app > div > aside {
  border-color: var(--theme-line);
  background: var(--theme-sidebar);
  color: var(--theme-sidebar-text);
}
#app > div > aside .text-slate-500,
#app > div > aside .text-slate-600 { color: var(--theme-sidebar-muted); }
#app > div > aside .border-slate-100,
#app > div > aside .border-slate-200 { border-color: var(--theme-line); }
#app > div > section { background: var(--theme-background); color: var(--theme-text); }
#app > section {
  background:
    radial-gradient(ellipse at 20% 12%, color-mix(in srgb, var(--theme-primary) 14%, transparent), transparent 38%),
    radial-gradient(ellipse at 85% 90%, color-mix(in srgb, var(--theme-secondary) 12%, transparent), transparent 34%),
    var(--theme-background);
  color: var(--theme-text);
}
#app > section > div { border-color: color-mix(in srgb, var(--theme-card) 90%, transparent); }
#app .bg-white,
#app .bg-white\/95 { background-color: var(--theme-card); color: var(--theme-card-text); }
#app .bg-white .text-slate-900,
#app .bg-white .text-slate-800,
#app .bg-white .text-slate-700 { color: var(--theme-card-text); }
#app .bg-white .text-slate-600,
#app .bg-white .text-slate-500,
#app .bg-white .text-slate-400 { color: var(--theme-card-muted); }
#app .bg-slate-50 { background-color: color-mix(in srgb, var(--theme-background) 90%, var(--theme-text)); }
#app .bg-slate-100 { background-color: color-mix(in srgb, var(--theme-card) 88%, var(--theme-text)); }
#app .text-slate-900,
#app .text-slate-800,
#app .text-slate-700 { color: var(--theme-text); }
#app .text-slate-600,
#app .text-slate-500,
#app .text-slate-400 { color: var(--theme-muted); }
#app .border-slate-100,
#app .border-slate-200 { border-color: var(--theme-line); }
#app .bg-indigo-600 { background-color: var(--theme-primary); color: var(--theme-primary-text); }
#app .bg-indigo-700 { background-color: var(--theme-primary-hover); color: var(--theme-primary-text); }
#app .hover\:bg-indigo-700:hover { background-color: var(--theme-primary-hover); }
#app .text-indigo-600,
#app .text-indigo-700 { color: var(--theme-primary); }
#app .bg-indigo-50 { background-color: var(--theme-primary-soft); }
#app .border-indigo-600,
#app .border-indigo-500 { border-color: var(--theme-primary); }
#app input:focus,
#app select:focus,
#app textarea:focus { --tw-ring-color: var(--theme-focus, rgb(99 102 241 / 24%)); }
#app #realtime-indicator { border-color: var(--theme-line); background: color-mix(in srgb, var(--theme-card) 94%, transparent); color: var(--theme-muted); }
.machine-filter-panel,
.order-type-filter-panel { border-color: var(--theme-line); background: var(--theme-card); }
.machine-filter-panel > span,
.machine-filter-panel select,
.order-type-filter-panel > span,
.order-type-filter-panel select { color: var(--theme-text); }
.machine-filter-panel select,
.order-type-filter-panel select { background-color: var(--theme-background); }
.machine-filter-panel select option,
.order-type-filter-panel select option,
#app select option { background-color: var(--theme-card); color: var(--theme-card-text); }
#app table thead { background-color: var(--theme-background); color: var(--theme-muted); }
.machine-filter-panel > span svg { color: var(--theme-primary); }
.upload-progress-panel { border-color: color-mix(in srgb, var(--theme-primary) 24%, var(--theme-card)); background: color-mix(in srgb, var(--theme-primary) 5%, var(--theme-card)); }
.upload-progress-track { background: color-mix(in srgb, var(--theme-primary) 15%, var(--theme-card)); }
.upload-progress-track > span { background: linear-gradient(90deg, var(--theme-primary), var(--theme-secondary)); }
.upload-file-bubble { border-color: var(--theme-primary); background: linear-gradient(120deg, var(--theme-primary), var(--theme-secondary)); color: var(--theme-primary-text); }
.calculator-input-panel,
.calculator-price-card { border-color: var(--theme-line); background: var(--theme-card); color: var(--theme-card-text); }
.calculator-heading-icon { background: color-mix(in srgb, var(--theme-primary) 15%, var(--theme-card)); color: var(--theme-primary); }
.calculator-user-card { border-top-color: var(--theme-primary); }
.calculator-member-card { border-top-color: var(--theme-secondary); }
.calculator-savings { background: linear-gradient(115deg, var(--theme-secondary), color-mix(in srgb, var(--theme-secondary) 78%, #000)); }
#app .nav-item.bg-indigo-50 { background-color: var(--theme-primary); color: var(--theme-primary-text); }

.monitor-page,
.monitor-page:fullscreen { background: var(--theme-background); color: var(--theme-text); }
.monitor-sidebar { border-color: var(--theme-line); background: var(--theme-sidebar); color: var(--theme-sidebar-text); }
.monitor-sidebar-brand strong,
.monitor-sidebar-account strong { color: var(--theme-sidebar-text); }
.monitor-sidebar-brand span,
.monitor-sidebar-account span,
.monitor-nav-caption,
.monitor-nav-empty { color: var(--theme-sidebar-muted); }
.monitor-sidebar-nav > a,
.monitor-machine-nav-item { color: var(--theme-sidebar-muted); }
.monitor-sidebar-nav > a:hover,
.monitor-machine-nav-item:hover { background: color-mix(in srgb, var(--theme-primary) 12%, var(--theme-sidebar)); color: var(--theme-sidebar-text); }
.monitor-sidebar-nav > a.monitor-nav-active { border-color: var(--theme-primary); background: var(--theme-primary); color: var(--theme-primary-text); }
.monitor-machine-nav-item > strong { background: color-mix(in srgb, var(--theme-sidebar-text) 12%, var(--theme-sidebar)); color: var(--theme-sidebar-text); }
.monitor-sidebar-account { border-color: var(--theme-line); }
.monitor-sidebar-account button,
.monitor-topbar-actions #monitor-fullscreen { border-color: var(--theme-line); background: color-mix(in srgb, var(--theme-card) 90%, var(--theme-text)); color: var(--theme-text); }
.monitor-main { color: var(--theme-text); }
.monitor-topbar h1,
.monitor-board-heading h2 { color: var(--theme-text); }
.monitor-breadcrumb,
.monitor-board-heading > div > p:last-child,
.monitor-machine-title > span,
.monitor-machine-total,
.monitor-updated { color: var(--theme-muted); }
.monitor-filterbar .monitor-search-panel,
.monitor-filterbar .machine-filter-panel,
.monitor-filterbar .order-type-filter-panel,
.monitor-filterbar > section.mb-5 { border-color: var(--theme-line); background: var(--theme-card); }
.monitor-filterbar .monitor-search-panel > label,
.monitor-filterbar .machine-filter-panel > span,
.monitor-filterbar .order-type-filter-panel > span,
.monitor-filterbar > section.mb-5 p { color: var(--theme-muted); }
.monitor-filterbar .monitor-search-controls input,
.monitor-filterbar .machine-filter-panel select,
.monitor-filterbar .order-type-filter-panel > select,
.monitor-filterbar > section.mb-5 button,
.monitor-filterbar > section.mb-5 label { border-color: var(--theme-line); background: var(--theme-background); color: var(--theme-text); }
.monitor-filterbar .machine-filter-panel select option,
.monitor-filterbar .order-type-filter-panel > select option { background-color: var(--theme-card); color: var(--theme-card-text); }
.monitor-filterbar .monitor-search-controls button { border-color: var(--theme-line); background: var(--theme-background); color: var(--theme-text); }
.monitor-page .monitor-filterbar > section.mb-5 button[aria-pressed="true"] { background: var(--theme-primary); color: var(--theme-primary-text); }
.monitor-machine-section { border-color: var(--theme-line); background: var(--theme-card); }
.monitor-machine-heading { border-color: var(--theme-line); color: var(--theme-text); }
.monitor-machine-section .monitor-order-card { border-color: var(--theme-line); background: color-mix(in srgb, var(--theme-card) 94%, var(--theme-card-text)); color: var(--theme-card-text); }
.monitor-card-code { color: var(--theme-card-text); }
.monitor-card-customer,
.monitor-card-quantity strong,
.monitor-card-operator strong { color: var(--theme-card-text); }
.monitor-card-product,
.monitor-card-quantity,
.monitor-card-operator > div > span { color: var(--theme-card-muted); }
.monitor-card-status { border-color: var(--theme-line); background: var(--theme-background); }
.monitor-status-legend { border-color: var(--theme-line); background: var(--theme-card); color: var(--theme-muted); }
.monitor-more-card { border-color: var(--theme-primary); background: var(--theme-primary); color: var(--theme-primary-text); }
.monitor-board-empty,
.monitor-loading { border-color: var(--theme-line); background: var(--theme-card); color: var(--theme-muted); }
#monitor-logout,
#monitor-theme-settings { color: var(--theme-sidebar-muted); }

.theme-settings-panel {
  border: 1px solid var(--theme-line);
  border-radius: 1.25rem;
  background: var(--theme-card);
  padding: clamp(1rem, 3vw, 1.5rem);
  color: var(--theme-card-text);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--theme-text) 8%, transparent);
}
.theme-settings-panel h1 { margin: 0; font-size: 1.3rem; font-weight: 800; }
.theme-settings-panel header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.theme-settings-kicker { margin-bottom: .2rem; color: var(--theme-primary); font-size: .65rem; font-weight: 800; letter-spacing: .12em; }
.theme-modal-close { display: grid; width: 2.25rem; height: 2.25rem; place-items: center; border: 1px solid var(--theme-line); border-radius: .7rem; color: var(--theme-muted); font-size: 1.4rem; }
.theme-preset-section h2 { font-size: .95rem; font-weight: 750; }
.theme-preset-section > p,
.theme-color-field small { margin-top: .2rem; color: var(--theme-card-muted); font-size: .75rem; }
.theme-preset-grid { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.theme-preset-button { display: inline-flex; align-items: center; gap: .45rem; border: 1px solid var(--theme-line); border-radius: .75rem; background: var(--theme-background); padding: .45rem .65rem; color: var(--theme-text); font-size: .75rem; font-weight: 650; }
.theme-preset-button:hover { border-color: var(--theme-primary); }
.theme-preset-swatch { display: inline-flex; gap: .1rem; }
.theme-preset-swatch i { width: .65rem; height: .95rem; border: 1px solid color-mix(in srgb, var(--theme-text) 12%, transparent); border-radius: .2rem; }
.theme-color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .75rem; margin-top: 1.2rem; }
.theme-color-field { display: flex; min-width: 0; min-height: 4rem; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem; border: 1px solid var(--theme-line); border-radius: .8rem; background: var(--theme-background); padding: .65rem .75rem; color: var(--theme-text); font-size: .78rem; font-weight: 650; }
.theme-color-field input[type="color"] { width: 2.5rem; height: 2rem; overflow: hidden; border: 1px solid var(--theme-line); border-radius: .45rem; background: transparent; padding: .12rem; cursor: pointer; }
.theme-color-field input[type="color"]:disabled { opacity: .45; cursor: not-allowed; }
.theme-text-toggle { display: inline-flex; align-items: center; gap: .45rem; }
.theme-text-toggle input { accent-color: var(--theme-primary); }
.theme-color-field small { flex-basis: 100%; font-size: .67rem; font-weight: 400; }
.theme-live-preview { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.2rem; border: 1px solid var(--theme-line); border-radius: .9rem; background: var(--theme-background); padding: .85rem 1rem; }
.theme-live-preview > div > span { font-size: .8rem; font-weight: 750; }
.theme-live-preview p { margin-top: .15rem; color: var(--theme-muted); font-size: .7rem; }
.theme-preview-button,
.theme-save-button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border-radius: .7rem; background: var(--theme-primary); padding: .6rem .8rem; color: var(--theme-primary-text); font-size: .75rem; font-weight: 750; }
.theme-save-feedback { margin-top: .75rem; color: var(--theme-muted); font-size: .72rem; }
.theme-settings-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; margin-top: .65rem; }
.theme-reset-button { border: 1px solid var(--theme-line); border-radius: .7rem; background: var(--theme-card); padding: .6rem .8rem; color: var(--theme-text); font-size: .75rem; font-weight: 700; }
.theme-reset-button:hover,
.theme-modal-close:hover { border-color: var(--theme-primary); }
.theme-modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; overflow-y: auto; background: rgb(2 6 23 / 65%); padding: 1rem; }
.theme-settings-modal { width: min(100%, 48rem); max-height: min(92vh, 56rem); overflow-y: auto; }

@media (max-width: 560px) {
  .theme-live-preview { align-items: flex-start; flex-direction: column; }
  .theme-settings-actions > button { flex: 1 1 auto; }
}
