/* ==========================================================================
   Unstucker — theme layer on top of Bulma
   ========================================================================== */

:root {
  /* Hardtmann greens + a hint of the Starvo red */
  --bg: #f4f7f0;
  --bg-accent-1: rgba(92, 184, 64, 0.16);
  --bg-accent-2: rgba(250, 38, 1, 0.05);
  --surface: #ffffff;
  --surface-2: #f6f9f2;
  --surface-3: #ecf2e6;
  --border: #e1e8d8;
  --border-strong: #cad6bd;
  --text: #172c24;
  --text-muted: #53635a;
  --text-faint: #8a9a8f;

  --primary: #2f7d22;
  --primary-600: #256018;
  --primary-soft: #e7f3e0;
  --primary-contrast: #ffffff;
  --accent: #5cb840;

  --danger: #fa2601;
  --danger-600: #cf1e00;
  --danger-soft: #ffeae3;

  --success: #2f7d22;
  --success-soft: #e7f3e0;

  --warning: #b45309;
  --warning-soft: #fff4e5;

  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(23, 44, 36, 0.06);
  --shadow-md: 0 10px 30px -12px rgba(23, 44, 36, 0.18);
  --shadow-lg: 0 24px 60px -24px rgba(23, 44, 36, 0.35);
  --ring: 0 0 0 4px rgba(47, 125, 34, 0.2);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b130d;
    --bg-accent-1: rgba(92, 184, 64, 0.2);
    --bg-accent-2: rgba(250, 38, 1, 0.1);
    --surface: #121c15;
    --surface-2: #17241c;
    --surface-3: #1f2f24;
    --border: #26382c;
    --border-strong: #35493c;
    --text: #e9f2ea;
    --text-muted: #9cb3a2;
    --text-faint: #6c8175;
    --primary: #5cb840;
    --primary-600: #79ce5e;
    --primary-soft: rgba(92, 184, 64, 0.16);
    --accent: #79ce5e;
    --danger: #ff5a3c;
    --danger-600: #fa2601;
    --danger-soft: rgba(250, 38, 1, 0.16);
    --success: #5cb840;
    --success-soft: rgba(92, 184, 64, 0.16);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.16);
    --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, 0.75);
    --ring: 0 0 0 4px rgba(92, 184, 64, 0.3);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(60rem 40rem at 110% -10%, var(--bg-accent-1), transparent 60%),
    radial-gradient(50rem 40rem at -10% 0%, var(--bg-accent-2), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ------------------------------- brand -------------------------------- */

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(135deg, #256018, #5cb840);
  color: #fff;
  font-size: 1.15rem;
  box-shadow: 0 8px 20px -8px rgba(47, 125, 34, 0.75);
}

.brand-mark-sm {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 0.95rem;
}

/* ------------------------------- login -------------------------------- */

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.75rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
}

.auth-subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ------------------------------- topbar ------------------------------- */

.app-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.topbar-title {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 220px;
  min-width: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip #loggedUser {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------- layout ------------------------------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.5rem;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
  align-items: start;
  align-content: start;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: sticky;
  top: 5rem;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.8rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.nav-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-tab.is-active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: background 0.16s ease, color 0.16s ease;
}

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

.nav-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nav-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: inherit;
}

.nav-desc {
  font-size: 0.76rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panels {
  min-width: 0;
}

/* -------------------------------- card -------------------------------- */

.box-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
}

.panel-head {
  margin-bottom: 1.4rem;
}

.panel-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.panel-desc {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.panel-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* -------------------------------- forms ------------------------------- */

.field {
  margin-bottom: 1.15rem;
}

.label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.input-wrap {
  position: relative;
  display: block;
}

.input-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 0.9rem;
  pointer-events: none;
}

.input-prefix {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  pointer-events: none;
}

.input.has-icon {
  padding-left: 2.5rem;
}

.input.has-prefix {
  padding-left: 3rem;
}

.input,
.textarea,
.select select {
  width: 100%;
  height: auto;
  padding: 0.65rem 0.9rem;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.input::placeholder {
  color: var(--text-faint);
}

.input:hover {
  border-color: var(--text-faint);
}

.input:focus,
.input:focus-visible,
.textarea:focus,
.select select:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: var(--ring);
}

/* ------------------------------- toggles ------------------------------ */

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.55rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text);
  transition: border-color 0.16s ease, background 0.16s ease;
}

.toggle:hover {
  border-color: var(--border-strong);
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.18s ease;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
  transition: transform 0.18s ease;
}

.toggle input:checked + .toggle-track {
  background: var(--primary);
}

.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
}

.toggle input:focus-visible + .toggle-track {
  box-shadow: var(--ring);
}

.toggle-label {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.toggle-title {
  font-weight: 600;
}

.toggle-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.toggle-block {
  margin: 1.4rem 0;
  padding: 0.75rem 0.85rem;
}

/* ------------------------------- buttons ------------------------------ */

.button {
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

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

.button.is-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--primary-contrast);
  border-color: transparent;
  box-shadow: 0 10px 22px -12px rgba(47, 125, 34, 0.85);
}

.button.is-primary:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary));
  color: var(--primary-contrast);
}

.button.is-danger {
  background: linear-gradient(135deg, var(--danger), #ff6a4d);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 22px -12px rgba(250, 38, 1, 0.9);
}

.button.is-danger:hover {
  background: linear-gradient(135deg, var(--danger-600), var(--danger));
  color: #fff;
}

.button.is-light {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.button.is-light:hover {
  background: var(--surface-3);
  color: var(--text);
}

.button .icon-text {
  gap: 0.5rem;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

/* -------------------------------- badges ------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

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

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

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

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

/* ---------------------------- result / customer ----------------------- */

.result-slot {
  margin-top: 1.5rem;
}

.result-slot:empty {
  margin-top: 0;
}

.customer-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 1.4rem;
  animation: rise 0.22s ease;
}

.customer-card.is-success {
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
  background: var(--success-soft);
}

.cashout-success-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  align-items: center;
}

.customer-head {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.customer-head h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem 1.25rem;
  margin: 0 0 1.3rem;
}

.detail-grid dt {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.detail-grid dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
  word-break: break-word;
}

.detail-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------- footer ------------------------------ */

.app-footer {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.8rem;
}

/* ------------------------------- modal -------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(0.98);
  transition: transform 0.18s ease;
}

.modal-backdrop.is-open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.modal-card[data-tone="danger"] .modal-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
}

.modal-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-details {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 0.4rem;
}

.modal-details li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--text);
}

.modal-details li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.modal-card[data-tone="danger"] .modal-details li::before {
  background: var(--danger);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.modal-card[data-tone="danger"] #confirmOk {
  background: linear-gradient(135deg, var(--danger), #ff6a4d);
  box-shadow: 0 10px 22px -12px rgba(250, 38, 1, 0.9);
}

.modal-card[data-tone="danger"] #confirmOk:hover {
  background: linear-gradient(135deg, var(--danger-600), var(--danger));
}

/* ------------------------------- toasts ------------------------------- */

.toast-container {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(380px, calc(100vw - 2.5rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-faint);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slide-in 0.2s ease;
}

.toast-leaving {
  animation: slide-out 0.2s ease forwards;
}

.toast-icon {
  flex: none;
  font-size: 1rem;
  margin-top: 1px;
}

.toast-success {
  border-left-color: var(--success);
}

.toast-success .toast-icon {
  color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-error .toast-icon {
  color: var(--danger);
}

.toast-info {
  border-left-color: var(--primary);
}

.toast-info .toast-icon {
  color: var(--primary);
}

.toast-text {
  flex: 1;
  font-size: 0.87rem;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}

.toast-close {
  flex: none;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

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

/* ----------------------------- animations ----------------------------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slide-out {
  to { opacity: 0; transform: translateX(16px); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ----------------------------- responsive ----------------------------- */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 1.1rem;
    padding: 1.25rem 1rem 2.5rem;
  }

  /* Tools become a tidy grid instead of a horizontally scrolling strip */
  .side-nav {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 0.5rem;
    overflow: visible;
  }

  .nav-tab {
    width: 100%;
    min-width: 0;
    padding: 0.7rem;
  }

  .nav-desc {
    display: none;
  }
}

@media (max-width: 560px) {
  .auth-card {
    padding: 1.6rem 1.3rem;
  }

  .box-card {
    padding: 1.35rem;
  }

  .topbar {
    padding: 0.7rem 1rem;
  }

  .topbar-title {
    display: none;
  }

  .user-chip {
    max-width: 120px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .button {
    width: 100%;
  }

  .toast-container {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
    width: auto;
  }
}
