:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-strong: #f1f5f9;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --accent-dark: #1e3a8a;
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --done: #10b981;
  --done-soft: #d1fae5;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.02);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  transition: all 0.2s ease;
}

.shadow-sm { box-shadow: var(--shadow-sm); }

.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-links {
  display: flex;
  gap: 16px;
}

.company-switcher {
  display: grid;
  gap: 4px;
  min-width: min(320px, 42vw);
}

.company-switcher span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.company-switcher select {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
}

.nav-btn {
  background: transparent;
  border: none;
  font-weight: 600;
  font-size: 1rem;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 8px;
}

.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-btn:hover:not(.active) {
  background: var(--surface-strong);
  color: var(--ink);
}

.view-hidden {
  display: none !important;
}

.app-header.client-header {
  padding: 0 0 24px 0;
}

h1, h2, h3, h4, p { margin: 0; }

h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: 0;
  color: var(--ink);
}

h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.header-actions, .panel-heading, .section-heading, .toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status-pill, .mini-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 12px;
}

.ghost-button, .icon-button, .primary-button, .action-button, .danger-button {
  border: 0;
  border-radius: 12px;
  min-height: 48px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 16px;
}

.ghost-button:hover { background: var(--surface-strong); }

.primary-button {
  width: 100%;
  background: var(--accent);
  color: white;
  padding: 0 24px;
  font-size: 1rem;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.primary-button:disabled {
  background: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}

.danger-button {
  background: #ef4444;
  color: white;
  padding: 0 16px;
  min-height: 38px;
  border-radius: 8px;
}
.danger-button:hover { background: #dc2626; }

.app-shell {
  display: grid;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px);
  max-width: 1400px;
  margin: 0 auto;
}

#clientView.app-shell {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.admin-layout.app-shell {
  grid-template-columns: 400px minmax(0, 1fr);
}

.panel, .orders-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}

.cart-panel {
  position: sticky;
  top: 96px;
  height: fit-content;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.field span {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  padding: 14px 16px;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.summary-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 24px 0;
}

.summary-block div {
  background: var(--surface-strong);
  border-radius: 12px;
  padding: 16px;
}

.summary-block span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.summary-block strong {
  font-size: 1.25rem;
  color: var(--ink);
}

.toolbar { margin-bottom: 24px; }

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-button {
  border: none;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  line-height: 1;
  padding: 12px 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  border: 1px solid transparent;
}

.tab-button.active {
  background: var(--ink);
  color: white;
}

.tab-button:hover:not(.active) {
  border-color: var(--line);
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.menu-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  transition: transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.menu-item-img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  background-color: #fff;
  border-bottom: 1px solid var(--line);
}

.menu-card-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-grow: 1;
}

.menu-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.menu-card h3 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin-bottom: 4px;
}

.price {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
}

.description {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  flex-grow: 1;
}

.add-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.tag {
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 10px;
}

.action-button {
  background: var(--accent-soft);
  color: var(--accent);
  min-width: 100px;
  padding: 0 16px;
  min-height: 40px;
  border-radius: 8px;
}

.action-button:hover { background: var(--accent); color: white; }

.cart-list, .admin-menu-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.cart-item, .admin-menu-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.cart-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.cart-item-top strong { font-size: 1rem; }

.qty-control {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-strong);
  padding: 4px;
  border-radius: 8px;
}

.icon-button {
  width: 32px;
  min-height: 32px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
}

.icon-button:hover { background: var(--line); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  padding: 40px 24px;
  text-align: center;
}

.empty-icon { color: var(--line); margin-bottom: 8px; }

.orders-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.order-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.order-card[data-status="cozinha"] { background: var(--warn-soft); border-color: rgba(245, 158, 11, 0.2); }
.order-card[data-status="servido"] { background: var(--accent-soft); border-color: rgba(37, 99, 235, 0.2); }
.order-card[data-status="consumido"] { background: var(--done-soft); border-color: rgba(16, 185, 129, 0.2); }

.order-items {
  list-style: none;
  padding: 0; margin: 0;
  display: grid; gap: 8px;
}

.order-items li {
  display: flex; justify-content: space-between;
  font-size: 0.95rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.add-item-form {
  background: var(--surface-strong);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.add-item-form input, .add-item-form textarea {
  background: var(--surface);
  margin-bottom: 0;
}

.add-item-form textarea { margin-bottom: 16px; }

.admin-menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
}

.category-admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 8px;
}

.category-admin-row .ghost-button {
  min-height: 32px;
  padding: 0 10px;
  color: #ef4444;
}

.order-note {
  padding: 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 8px;
}

.admin-menu-desc { flex-grow: 1; margin-right: 16px; }
.admin-menu-desc h4 { margin: 0 0 4px 0; font-size: 1rem; }
.admin-menu-desc p { color: var(--muted); font-size: 0.85rem; }

@media (max-width: 992px) {
  #clientView.app-shell, .admin-layout.app-shell { grid-template-columns: 1fr; }
  .cart-panel { position: static; }
  .app-nav {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }
  .company-switcher {
    min-width: 100%;
  }
}
