/* ==========================================================================
   Tillwise Dashboard - app styles
   ========================================================================== */

:root {
  --accent: #e8542a;
  --accent-dim: #a83f21;
  --bg: #12161c;
  --bg-raised: #181d25;
  --bg-card: #1c222b;
  --bg-card-hover: #212832;
  --border: #2a313c;
  --border-soft: #232a34;
  --cream: #fbf3ea;
  --text: #f2ede6;
  --text-dim: #9aa3b0;
  --text-faint: #6b7382;
  --green: #38b874;
  --green-bg: rgba(56, 184, 116, 0.14);
  --amber: #e8a939;
  --amber-bg: rgba(232, 169, 57, 0.16);
  --red: #e8542a;
  --red-bg: rgba(232, 84, 42, 0.16);
  --neutral-bg: rgba(154, 163, 176, 0.14);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}

button, input {
  font-family: inherit;
  color: inherit;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

h1, h2, p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

img {
  max-width: 100%;
  display: block;
}

/* ==========================================================================
   Login screen
   ========================================================================== */

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, var(--safe-top)) 20px max(24px, var(--safe-bottom));
  background:
    radial-gradient(circle at 50% 0%, rgba(232, 84, 42, 0.14), transparent 55%),
    var(--bg);
}

.login-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.login-logo img {
  width: 44px;
  height: 44px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login-subtitle {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 14.5px;
}

.login-form {
  width: 100%;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
}

.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

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

.field input:focus {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.login-error {
  background: var(--red-bg);
  border: 1px solid rgba(232, 84, 42, 0.35);
  color: #ff9c7d;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
  line-height: 1.4;
}

.login-footnote {
  margin-top: 22px;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.5;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, filter 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #17110d;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: default;
}

.btn-block {
  width: 100%;
}

.btn-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(23, 17, 13, 0.35);
  border-top-color: #17110d;
  animation: spin 0.7s linear infinite;
}

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

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

/* ==========================================================================
   App shell
   ========================================================================== */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, var(--safe-top)) 18px 12px;
  background: rgba(18, 22, 28, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}

.app-header-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.business-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.updated-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12.5px;
}

.updated-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--green-bg);
}

.updated-pill.is-stale .updated-dot {
  background: var(--text-faint);
  box-shadow: 0 0 0 3px rgba(154, 163, 176, 0.12);
}

.updated-pill.is-stale #updated-text {
  color: var(--text-faint);
}

.updated-pill.is-error .updated-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--red-bg);
}

.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px calc(100px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.panel-content {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* ==========================================================================
   Empty states
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 64px 20px 40px;
  color: var(--text-dim);
}

.empty-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.empty-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
}

.empty-body {
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 280px;
}

.empty-state-inline {
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
  padding: 28px 12px;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.hero-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 20px;
  background: linear-gradient(160deg, var(--bg-card) 0%, var(--bg-raised) 100%);
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(232, 84, 42, 0.16), transparent 70%);
  pointer-events: none;
}

.hero-label {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.hero-number {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--cream);
  line-height: 1.15;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.hero-sub {
  font-size: 13.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ==========================================================================
   Lists - orders / staff / inventory
   ========================================================================== */

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
}

.list-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.list-row-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-row-meta {
  font-size: 12.5px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.list-row-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.list-row-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dot-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

/* ==========================================================================
   Status pills / badges
   ========================================================================== */

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: 0.01em;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--text-dim);
}

.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-neutral { background: var(--neutral-bg); color: var(--text-dim); }
.pill-accent { background: var(--red-bg); color: #ff9c7d; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

/* ==========================================================================
   Kitchen order cards
   ========================================================================== */

.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 16px;
}

.order-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.order-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.order-card-time {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: 8px;
  font-weight: 500;
}

.order-items {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.order-item-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
}

.order-item-qty {
  color: var(--cream);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 22px;
}

/* ==========================================================================
   Inventory stock bar
   ========================================================================== */

.stock-bar-track {
  width: 64px;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-raised);
  overflow: hidden;
  flex-shrink: 0;
}

.stock-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--amber);
}

.stock-bar-fill.is-critical {
  background: var(--accent);
}

.stock-figure {
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.stock-figure.is-critical {
  color: #ff9c7d;
}

/* ==========================================================================
   Bottom tab bar
   ========================================================================== */

.tab-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: rgba(18, 22, 28, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-soft);
  padding: 6px 6px max(6px, var(--safe-bottom));
}

.tab-btn {
  flex: 1;
  max-width: 120px;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 6px;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
  transition: color 0.15s ease;
}

.tab-btn svg {
  transition: transform 0.15s ease;
}

.tab-btn.is-active {
  color: var(--accent);
}

.tab-btn:active svg {
  transform: scale(0.9);
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}

/* ==========================================================================
   Responsive - wider screens / tablets
   ========================================================================== */

@media (min-width: 640px) {
  .app {
    max-width: 560px;
    border-left: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.35);
  }

  body {
    background: #0b0e12;
  }

  .tab-bar {
    border-radius: 0;
  }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
