:root {
  color-scheme: light;
  --bg: #f5f5fa;
  --bg-gradient: radial-gradient(1200px 600px at 10% -10%, #ece7ff 0%, transparent 55%),
    radial-gradient(900px 500px at 110% 10%, #e3f4ff 0%, transparent 50%);
  --surface: #ffffff;
  --surface-2: #fafafd;
  --text: #17171c;
  --muted: #6d6d7a;
  --line: #e7e7ef;
  --line-strong: #d6d6e2;
  --primary: #6b4eff;
  --primary-strong: #5638e8;
  --primary-soft: #efeaff;
  --primary-soft-text: #5638e8;
  --success: #0f9d63;
  --success-soft: #e5f7ef;
  --danger: #dc3d43;
  --danger-soft: #fdecec;
  --warning: #b26a00;
  --warning-soft: #fff4e0;
  --shadow-sm: 0 1px 2px rgba(20, 20, 40, 0.05), 0 1px 3px rgba(20, 20, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(20, 20, 45, 0.08);
  --shadow-lg: 0 24px 60px rgba(20, 20, 45, 0.16);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 9px;
  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e0e13;
    --bg-gradient: radial-gradient(1200px 600px at 10% -10%, #241d45 0%, transparent 55%),
      radial-gradient(900px 500px at 110% 10%, #102c3a 0%, transparent 50%);
    --surface: #181820;
    --surface-2: #1e1e28;
    --text: #f1f1f6;
    --muted: #9b9bab;
    --line: #2a2a36;
    --line-strong: #3a3a49;
    --primary: #8b74ff;
    --primary-strong: #a290ff;
    --primary-soft: #262043;
    --primary-soft-text: #b7a7ff;
    --success: #35c98d;
    --success-soft: #102b22;
    --danger: #ff6b70;
    --danger-soft: #2e1518;
    --warning: #ffb44d;
    --warning-soft: #2e2412;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-gradient), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 16px;
}

p {
  margin: 0;
}

a {
  color: var(--primary-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.hidden,
[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
}

.dialog-body .table {
  min-width: 0;
}

.products.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.small {
  font-size: 13px;
}

.tiny {
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

/* ---------- Layout ---------- */
.page {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px 132px;
}

.admin-page {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 12px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #7c5cff 0%, #4d8dff 100%);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 6px 14px rgba(107, 78, 255, 0.32);
  flex: none;
}

.brand-text {
  min-width: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.topbar-spacer {
  flex: 1;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.icon-link:hover {
  color: var(--text);
  border-color: var(--line-strong);
  text-decoration: none;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card + .card {
  margin-top: 14px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 24px;
  background: linear-gradient(150deg, #6b4eff 0%, #4d7dff 100%);
  border: none;
  color: #fff;
}

.hero::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -90px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
}

.hero::before {
  content: "";
  position: absolute;
  right: 60px;
  bottom: -120px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: 25px;
  margin-bottom: 6px;
}

.hero .hero-sub {
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  max-width: 420px;
}

.hero-date {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.employee-pick {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-top: 20px;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  text-align: left;
  transition: background 0.15s ease, transform 0.1s ease;
}

.employee-pick:hover {
  background: rgba(255, 255, 255, 0.22);
}

.employee-pick:active {
  transform: scale(0.995);
}

.employee-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-weight: 700;
  font-size: 16px;
  flex: none;
}

.employee-pick-text {
  flex: 1;
  min-width: 0;
}

.employee-pick-name {
  display: block;
  font-weight: 650;
  font-size: 15.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.employee-pick-hint {
  display: block;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.employee-pick .chevron {
  flex: none;
  opacity: 0.8;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  border-color: transparent;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(107, 78, 255, 0.28);
}

.btn-primary:hover {
  background: var(--primary-strong);
  border-color: transparent;
}

.btn-danger {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  border-color: transparent;
  background: var(--success);
  color: #fff;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 9px;
}

.btn-lg {
  min-height: 50px;
  padding: 14px 24px;
  font-size: 16px;
  border-radius: 14px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 9px;
  font-size: 15px;
}

.btn .spinner {
  width: 15px;
  height: 15px;
}

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 15px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  width: 19px;
  height: 19px;
  accent-color: var(--primary);
  cursor: pointer;
}

.field .checkbox + .checkbox {
  margin-top: 9px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.form-row > .field {
  height: 100%;
  margin-bottom: 0;
}

.form-row .field-label {
  min-height: 34px;
  display: flex;
  align-items: flex-end;
  line-height: 1.25;
}

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

.product.is-sub {
  margin-left: 6px;
  padding-left: 14px;
  border-left: 2px solid var(--primary-soft);
}

.product.is-sub .product-name {
  font-size: 14px;
  font-weight: 600;
}

.product.is-sub .product-meta {
  font-size: 12px;
}

.progress-plan {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-size: 13px;
  font-weight: 650;
}

.progress-target {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 550;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cal-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.cal-work {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
}

.cal-report {
  background: var(--success);
}

.cal-off {
  background: var(--warning);
}

.cal-holiday {
  background: var(--danger);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.calendar-weekday {
  padding: 4px 6px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
}

.calendar-cell {
  min-height: 58px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
}

.calendar-cell small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.calendar-cell.is-weekend {
  background: var(--surface-2);
  color: var(--muted);
}

.calendar-cell.is-report {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.calendar-cell.is-off {
  border-color: var(--warning);
  background: var(--warning-soft);
  color: var(--warning);
}

.calendar-cell.is-holiday {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.calendar-cell.is-empty {
  visibility: hidden;
}

.method-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.method-box h4 {
  margin: 0 0 4px;
  font-size: 15px;
}

.method-role {
  margin: 14px 0 8px;
  color: var(--primary-soft-text);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.05em;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.method-grid .field {
  height: 100%;
  margin-bottom: 0;
  justify-content: flex-end;
}

.method-grid .field-label {
  min-height: 34px;
  display: flex;
  align-items: flex-end;
  font-size: 11px;
  line-height: 1.2;
}

@media (max-width: 900px) {
  .method-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.method-result {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.method-result b {
  color: var(--text);
  font-size: 16px;
}

.method-total {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-size: 16px;
  font-weight: 750;
}

.zls-units,
.fot-split {
  grid-column: 1 / -1;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.zls-units {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.zls-unit {
  padding: 9px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.zls-unit-title,
.fot-split-title {
  margin-bottom: 7px;
  color: var(--primary-soft-text);
  font-size: 12px;
  font-weight: 750;
}

.zls-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.zls-field input {
  width: 92px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: right;
}

.fot-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

.fot-split-title,
.fot-hint {
  grid-column: 1 / -1;
}

.fot-hint {
  color: var(--muted);
  font-size: 11px;
}

.product {
  flex-wrap: wrap;
}

.up-card {
  padding: 16px 18px;
}

.plan-card {
  padding: 16px 18px;
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
  margin-top: 10px;
}

.plan-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.plan-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.plan-grid strong {
  font-size: 19px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.plan-grid small {
  color: var(--muted);
  font-size: 12px;
}

.plan-wide {
  grid-column: 1 / -1;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.up-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.up-values {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 6px;
}

.up-input {
  width: 140px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 34px;
  font-weight: 780;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}

.up-input::-webkit-outer-spin-button,
.up-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.up-input:focus {
  outline: none;
  border-bottom: 2px solid var(--primary);
}

.up-values strong {
  font-size: 30px;
  font-weight: 780;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.up-track {
  height: 8px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.up-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7c5cff, #4d8dff);
  transition: width 0.2s ease;
}

.up-fill.is-low {
  background: linear-gradient(90deg, #f5a524, #ff7a45);
}

/* ---------- Products ---------- */
.products {
  display: flex;
  flex-direction: column;
}

.product {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.product:last-child {
  border-bottom: none;
}

.product-name {
  font-weight: 600;
  font-size: 15px;
}

.product-meta {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.product-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.qty {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.qty button {
  width: 34px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
}

.qty button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.qty input {
  width: 50px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  appearance: textfield;
  -moz-appearance: textfield;
}

.qty-wide input {
  width: 102px;
}

.qty input::-webkit-outer-spin-button,
.qty input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.product-sum {
  min-width: 82px;
  text-align: right;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.product-manual {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--muted);
}

.product-manual input {
  width: 130px;
  min-height: 36px;
  margin-left: auto;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  text-align: right;
  font-size: 14px;
}

.product.is-zero .product-sum {
  color: var(--muted);
  font-weight: 500;
}

.empty {
  padding: 30px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Status / badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary-soft-text);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- Sticky total ---------- */
.sticky-total {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.sticky-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 648px;
  margin: 0 auto;
}

.sticky-sum {
  flex: 1;
  min-width: 0;
}

.sticky-sum-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.sticky-sum-value {
  font-size: 23px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.sticky-inner .btn {
  min-width: 170px;
}

/* ---------- Dialog ---------- */
dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(12, 12, 20, 0.45);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
}

.dialog-body {
  max-height: calc(86vh - 140px);
  padding: 4px 20px 20px;
  overflow-y: auto;
}

.dialog-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 18px;
}

.employee-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.employee-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  width: 100%;
}

.employee-option:hover {
  background: var(--surface-2);
}

.employee-option.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.employee-option .avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-weight: 700;
  flex: none;
}

.employee-option-name {
  font-weight: 600;
}

.employee-option-pos {
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- Success ---------- */
.success-box {
  padding: 30px 24px 8px;
  text-align: center;
}

.success-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  font-size: 34px;
}

.success-total {
  margin: 14px 0 4px;
  font-size: 32px;
  font-weight: 780;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

/* ---------- History ---------- */
.history-list {
  display: flex;
  flex-direction: column;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.history-row:last-child {
  border-bottom: none;
}

.history-date {
  flex: 1;
  font-weight: 550;
}

.history-total {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

details.history-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

details.history-details summary::-webkit-details-marker {
  display: none;
}

details.history-details summary::before {
  content: "▸";
  font-size: 11px;
  transition: transform 0.15s ease;
}

details.history-details[open] summary::before {
  transform: rotate(90deg);
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 13px;
  background: #1e1e28;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease;
}

.toast-error {
  background: #b3262c;
}

.toast-success {
  background: #107a50;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Spinner ---------- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Admin ---------- */
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.login-card {
  width: min(400px, 100%);
  padding: 30px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.admin-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 0 14px;
}

.admin-header .brand {
  flex: none;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 5px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 1;
  min-width: max-content;
  padding: 9px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  background: var(--primary-soft);
  color: var(--primary-soft-text);
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.view-head h2 {
  font-size: 22px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar .input,
.toolbar .select {
  width: auto;
  min-width: 150px;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 14px;
}

.toolbar .select {
  padding-right: 36px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  height: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.kpi-value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.kpi-accent {
  background: linear-gradient(150deg, #6b4eff 0%, #4d7dff 100%);
  border: none;
  color: #fff;
}

.kpi-accent .kpi-label,
.kpi-accent .kpi-sub {
  color: rgba(255, 255, 255, 0.76);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
  align-items: start;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 560px;
}

.table th {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table .actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.cell-main {
  font-weight: 600;
}

.cell-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.product-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  font-size: 13px;
}

.bar-track {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7c5cff, #4d8dff);
}

.report-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin-bottom: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  font-size: 13px;
}

.view-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.view-row:last-child {
  border-bottom: none;
}

.view-info {
  flex: 1;
  min-width: 0;
}

.view-row .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.edit-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 110px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.edit-item:last-child {
  border-bottom: none;
}

.edit-item-info {
  min-width: 0;
}

.edit-qty,
.edit-amount {
  min-height: 38px;
  padding: 6px 9px;
  text-align: right;
}

@media (max-width: 560px) {
  .edit-item {
    grid-template-columns: minmax(0, 1fr) 78px;
  }
  .edit-item .edit-amount {
    grid-column: 1 / -1;
  }
  .view-row {
    flex-wrap: wrap;
  }
  .view-row .actions {
    width: 100%;
    justify-content: flex-start;
  }
  .reports-details summary {
    font-size: 14px;
  }
}

.reports-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  list-style: none;
}

.reports-details summary::-webkit-details-marker {
  display: none;
}

.reports-details summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.reports-details[open] summary::before {
  transform: rotate(90deg);
}

.report-summary strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state .emoji {
  font-size: 30px;
  margin-bottom: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

.settings-grid .card {
  margin-top: 0;
}

.bot-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 14px;
  font-size: 13px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.kv:last-child {
  border-bottom: none;
}

.kv-key {
  color: var(--muted);
}

.kv-val {
  text-align: right;
  font-weight: 600;
  word-break: break-all;
}

.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.alert-info {
  background: var(--primary-soft);
  color: var(--primary-soft-text);
}

.alert-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- Simulator ---------- */
.sim-shell {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.sim-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.sim-header .brand-text {
  min-width: 0;
}

.sim-header .brand-name,
.sim-header .brand-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sim-header .icon-link {
  flex: none;
}

.sim-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c5cff, #4d8dff);
  color: #fff;
  font-weight: 700;
}

.sim-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  overflow-y: auto;
}

.bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.bubble-in {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}

.bubble-out {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.bubble-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.bubble-btn {
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.bubble-btn:hover {
  border-color: var(--primary);
  text-decoration: none;
}

.sim-composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.sim-composer .input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
}

.sim-quick {
  display: flex;
  gap: 6px;
  padding: 8px 12px 0;
  overflow-x: auto;
  background: var(--surface);
}

.sim-quick .btn {
  flex: none;
}

.sim-foot {
  padding: 8px 12px 10px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Landing ---------- */
.landing {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.landing-card {
  width: min(760px, 100%);
}

.landing-hero {
  padding: 38px 32px;
  border-radius: 26px;
  background: linear-gradient(150deg, #6b4eff 0%, #4d7dff 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.landing-hero h1 {
  font-size: 32px;
  margin: 14px 0 8px;
}

.landing-hero p {
  color: rgba(255, 255, 255, 0.82);
  max-width: 540px;
}

.landing-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}

.landing-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  text-decoration: none;
}

.landing-link:hover {
  background: rgba(255, 255, 255, 0.22);
  text-decoration: none;
}

.landing-link strong {
  font-size: 15px;
}

.landing-link span {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.75);
}

.landing-note {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .grid-2,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 14.5px;
  }
  .page {
    padding: 0 12px 128px;
  }
  .admin-page {
    padding: 0 12px 60px;
  }
  .topbar-inner {
    padding: 0 12px;
  }
  .hero {
    padding: 20px;
    border-radius: 16px;
  }
  .hero h1 {
    font-size: 22px;
  }
  .hero .hero-sub {
    font-size: 13px;
  }
  .card {
    padding: 16px;
    border-radius: 16px;
  }
  .product {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .product-controls {
    justify-content: space-between;
  }
  .product-controls {
    gap: 10px;
  }
  .product-sum {
    min-width: 64px;
    font-size: 14px;
  }
  .qty input {
    width: 42px;
  }
  .qty.qty-wide input {
    width: 92px;
  }
  .qty button {
    width: 31px;
  }
  .sticky-inner {
    gap: 10px;
  }
  .sticky-sum-value {
    font-size: 20px;
  }
  .sticky-inner .btn {
    min-width: 0;
    flex: 1;
    max-width: 200px;
  }
  .landing-hero {
    padding: 28px 22px;
  }
  .landing-hero h1 {
    font-size: 26px;
  }
  .landing-actions {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .view-head h2 {
    font-size: 19px;
  }
  .kpi {
    padding: 13px;
  }
  .kpi-value {
    font-size: 20px;
  }
  .admin-header {
    padding: 12px 0 10px;
  }
  .admin-header .brand-sub {
    display: none;
  }

  dialog {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    max-height: 92vh;
    margin: 0 auto;
    border-radius: 22px 22px 0 0;
  }

  .dialog-body {
    max-height: calc(92vh - 150px);
  }

  .up-values strong {
    font-size: 26px;
  }

  .product {
    padding: 11px 0;
  }

  .product.is-sub {
    margin-left: 0;
    padding-left: 12px;
  }

  .tabs {
    flex-wrap: wrap;
    overflow: visible;
  }

  .tab {
    flex: 1 0 30%;
    padding: 9px 10px;
    font-size: 13px;
  }

  .view-head .toolbar {
    width: 100%;
    gap: 8px;
  }

  .view-head .toolbar .input,
  .view-head .toolbar .select {
    flex: 1 1 140px;
    min-width: 0;
  }

  .view-head .toolbar .btn {
    flex: 0 0 auto;
  }

  .table-wrap {
    border: none;
    background: transparent;
    overflow: visible;
  }

  .table-wrap table.table {
    display: block;
    min-width: 0;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .table-wrap tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .table-wrap tbody tr:hover {
    background: var(--surface);
  }

  .table-wrap td {
    display: block;
    min-width: 0;
    padding: 0;
    border: none;
  }

  .table-wrap td.num {
    text-align: left;
  }

  .table-wrap td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .table-wrap td[data-label=""]::before {
    display: none;
  }

  .table-wrap td.actions {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 2px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }

  .table-wrap td.empty-state {
    grid-column: 1 / -1;
    text-align: center;
  }

  .table-wrap td.empty-state::before {
    display: none;
  }
}

@media (max-width: 480px) {
  .sim-header .badge {
    display: none;
  }

  .sim-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .sim-header .brand-sub {
    font-size: 10.5px;
  }
}
