/* ============================================================
   RUMI FOODS ERP — Design System
   Cores extraídas do logotipo Rumi Foods
   Fonte: Sora (Google Fonts)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --primary:       #2BADA0;
  --primary-dark:  #1f8a7e;
  --primary-light: #3dd4c5;
  --accent:        #F5C518;
  --accent-dark:   #d4a800;
  --black:         #1A1A1A;
  --red:           #C0392B;
  --red-light:     #f8d7da;
  --yellow:        #F39C12;
  --yellow-light:  #fff3cd;
  --green:         #27AE60;
  --green-light:   #d4edda;
  --white:         #FFFFFF;
  --bg:            #F5F7F7;
  --card:          #FFFFFF;
  --border:        #E2E8F0;
  --text:          #1A1A1A;
  --text-muted:    #6B7280;
  --text-light:    #9CA3AF;
  --sidebar-w:     260px;
  --header-h:      64px;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:     0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.08);
  --transition:    all 0.2s ease;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; }

/* ── Layout ────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--black);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform 0.3s ease;
  overflow: hidden;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
}

.sidebar-logo-text .brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.02em;
}

.sidebar-logo-text .version {
  font-size: 0.65rem;
  color: var(--primary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: var(--transition);
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
  border-left-color: rgba(43,173,160,0.5);
}

.nav-item.active {
  background: rgba(43,173,160,0.15);
  color: var(--primary-light);
  border-left-color: var(--primary);
}

.nav-item .nav-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info .user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--white);
  display: block;
}

.user-info .user-role {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
}

.logout-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.logout-btn:hover { color: var(--red); }

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* a causa raiz da maioria dos "transborda" desta varredura:
    um item flex, por omissão, nunca encolhe abaixo do tamanho do seu
    conteúdo mais largo (min-width:auto implícito) — mesmo que esse
    conteúdo (uma tabela, uma barra de filtros) já tenha o seu próprio
    scroll interno. Sem isto, .main-content empurrava a página toda para
    fora do ecrã em vez de deixar o filho lidar com o excesso sozinho. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────── */
.top-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.hamburger {
  display: none;
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
}

/* O breadcrumb é o único elemento da barra com largura elástica — sem
   min-width:0 aqui, o flexbox nunca o deixa encolher abaixo do que o seu
   texto mede, e é isso que empurrava o botão para fora do ecrã num
   telemóvel. Em vez de a barra alargar, o texto agora corta com "…". */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
}

.breadcrumb .crumb {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.breadcrumb .crumb.active { color: var(--text); font-weight: 600; }
.breadcrumb .sep { color: var(--text-light); flex-shrink: 0; }

.header-actions {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Sora', sans-serif;
}

.header-btn:hover { border-color: var(--primary); color: var(--primary); }

.btn-venda {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-venda:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: white;
}

/* ── Page Content ──────────────────────────────────────────── */
.page-content {
  flex: 1;
  min-width: 0; /* mesma razão que .main-content, um nível abaixo */
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 24px; }

/* ── KPI Cards ─────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
}

.kpi-card.primary::after { background: var(--primary); }
.kpi-card.accent::after  { background: var(--accent); }
.kpi-card.green::after   { background: var(--green); }
.kpi-card.red::after     { background: var(--red); }
.kpi-card.yellow::after  { background: var(--yellow); }

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

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.kpi-card.primary .kpi-icon { background: rgba(43,173,160,0.12); color: var(--primary); }
.kpi-card.accent .kpi-icon  { background: rgba(245,197,24,0.12); color: var(--accent-dark); }
.kpi-card.green .kpi-icon   { background: rgba(39,174,96,0.12); color: var(--green); }
.kpi-card.red .kpi-icon     { background: rgba(192,57,43,0.12); color: var(--red); }
.kpi-card.yellow .kpi-icon  { background: rgba(243,156,18,0.12); color: var(--yellow); }

.kpi-info { flex: 1; min-width: 0; }
.kpi-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1.2; margin-top: 2px; }
.kpi-change { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }

/* ── Module Hub Cards ──────────────────────────────────────── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.module-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.module-card:hover::before { transform: scaleX(1); }

.module-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--primary);
}

.module-card-icon {
  width: 56px;
  height: 56px;
  background: rgba(43,173,160,0.1);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.module-card-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.855rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  font-family: 'Sora', sans-serif;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: white; }

.btn-accent {
  background: var(--accent);
  color: var(--black);
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-success {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
.btn-success:hover { background: #1e9e4e; border-color: #1e9e4e; color: white; }

.btn-danger {
  background: var(--red);
  color: white;
  border-color: var(--red);
}
.btn-danger:hover { background: #a93226; border-color: #a93226; color: white; }

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

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

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 13px 24px; font-size: 0.95rem; }
.btn-icon { padding: 8px; min-width: 36px; justify-content: center; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius) 0 0; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(43,173,160,0.05); }

tbody td { padding: 12px 16px; color: var(--text); vertical-align: middle; }

tfoot tr { background: #f0f2f4; font-weight: 700; border-top: 2px solid var(--primary); }
tfoot td { padding: 12px 16px; font-size: 0.88rem; }

/* ── Stock Status Badges ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-green    { background: var(--green-light); color: #155724; }
.badge-yellow   { background: var(--yellow-light); color: #856404; }
.badge-red      { background: var(--red-light); color: #721c24; }
.badge-primary  { background: rgba(43,173,160,0.12); color: var(--primary-dark); }
.badge-muted    { background: #e9ecef; color: #495057; }
.badge-accent   { background: rgba(245,197,24,0.15); color: #92710a; }

/* Stock row colors */
.row-stock-ok     { background: rgba(39,174,96,0.06) !important; }
.row-stock-aviso  { background: rgba(243,156,18,0.08) !important; }
.row-stock-fora   { background: rgba(192,57,43,0.07) !important; }
.row-stock-ok:hover    { background: rgba(39,174,96,0.12) !important; }
.row-stock-aviso:hover { background: rgba(243,156,18,0.14) !important; }
.row-stock-fora:hover  { background: rgba(192,57,43,0.12) !important; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: 'Sora', sans-serif;
  color: var(--text);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43,173,160,0.12);
}

.form-control::placeholder { color: var(--text-light); }

select.form-control { cursor: pointer; }

.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--red); margin-top: 4px; }

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

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ── Flash Messages ────────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.flash {
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  position: relative;
  border-left: 4px solid;
}

.flash-success { background: var(--green-light); color: #155724; border-color: var(--green); }
.flash-error   { background: var(--red-light); color: #721c24; border-color: var(--red); }
.flash-info    { background: rgba(43,173,160,0.1); color: var(--primary-dark); border-color: var(--primary); }

.flash-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.6;
  padding: 0;
}

.confirm-overlay { position:fixed;inset:0;background:rgba(17,24,39,.48);display:none;align-items:center;justify-content:center;padding:20px;z-index:3000;backdrop-filter:blur(2px); }
.confirm-overlay.open { display:flex; }
.confirm-dialog { width:min(420px,100%);background:var(--white);border-radius:14px;padding:26px;text-align:center;box-shadow:0 24px 70px rgba(0,0,0,.25);animation:confirmIn .2s ease; }
.confirm-icon { width:52px;height:52px;margin:0 auto 14px;border-radius:50%;display:grid;place-items:center;background:var(--red-light);color:var(--red);font-size:1.45rem; }
.confirm-dialog h3 { margin:0 0 8px;font-size:1.1rem; }
.confirm-dialog p { margin:0;color:var(--text-muted);line-height:1.5; }
.confirm-actions { display:flex;justify-content:center;gap:10px;margin-top:22px; }
@keyframes confirmIn { from { opacity:0;transform:translateY(8px) scale(.97); } to { opacity:1;transform:none; } }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  backdrop-filter: blur(3px);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(-10px);
  transition: transform 0.25s ease;
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Search & Filters ──────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 380px;
}

.search-box input {
  padding-left: 38px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  margin-top: 20px;
}

.page-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Sora', sans-serif;
}

.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Grids ─────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 20px; }

.pagination-wrap { display:flex;flex-direction:column;align-items:center;justify-content:center;gap:9px;padding:14px 18px;text-align:center; }
.pagination-info { color:var(--text-muted);font-size:.8rem; }
.pagination { display:flex;align-items:center;gap:4px; }
.pagination-link { min-width:34px;height:34px;padding:0 9px;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--border);border-radius:7px;color:var(--text);font-size:.82rem;background:var(--white); }
.pagination-link:hover { border-color:var(--primary);color:var(--primary); }
.pagination-link.active { background:var(--primary);border-color:var(--primary);color:#fff;font-weight:700; }
.pagination-link.disabled { opacity:.4;pointer-events:none; }
.pagination-dots { padding:0 4px;color:var(--text-muted); }
.grid-3 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr); gap: 16px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

/* ── Utils ─────────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--green); }
.text-danger  { color: var(--red); }
.text-warning { color: var(--yellow); }
.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; flex-wrap: wrap; }
.flex-center { display: flex; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.d-none { display: none; }
.rounded { border-radius: var(--radius); }
.shadow { box-shadow: var(--shadow); }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; }

/* ── Loading ───────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(43,173,160,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── POS Layout ────────────────────────────────────────────── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  height: calc(100vh - var(--header-h) - 56px);
}

.pos-products {
  overflow-y: auto;
  padding-right: 4px;
}

.pos-cart {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.product-tile {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.product-tile:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.product-tile img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.product-tile .product-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}

.product-tile .product-price {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .pos-layout { grid-template-columns: 1fr; }
  .pos-cart { max-height: 50vh; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .hamburger { display: flex; }

  .page-content { padding: 16px; }
  .top-header { padding: 0 16px; gap: 10px; }

  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 190;
    display: none;
  }
  .sidebar-overlay.open { display: block; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }

  /* O botão "Registar Venda" fica só com o ícone — com o texto, era o que
     mais empurrava a barra de topo para fora da largura do ecrã. */
  .btn-venda-texto { display: none; }
  .btn-venda { padding: 8px 10px; }

  /* Num telemóvel, "Rumi Foods ›" antes da página actual só ocupa espaço
     que faz falta ao nome da própria página — que é o que importa aqui. */
  .breadcrumb .crumb:first-child,
  .breadcrumb .sep:first-of-type {
    display: none;
  }
}

/* Toda a tabela do projecto passou a ficar dentro de um invólucro com
   scroll horizontal próprio (ver views/*.ejs — <div class="table-scroll">).
   Sem isto, uma tabela larga (várias colunas de números) obrigava a página
   inteira a scrollar de lado num telemóvel. Aplicar overflow directamente
   em <table>, sem invólucro, funciona de forma inconsistente entre
   motores de navegador — por isso o Bootstrap também sempre exigiu uma
   div à volta em vez de estilar a tabela directamente. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Chart containers ──────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 240px;
}

/* ── Login Page ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1A1A1A 0%, #2d2d2d 50%, #1f3a38 100%);
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-circle {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 14px;
  box-shadow: 0 8px 20px rgba(43,173,160,0.35);
}

.login-brand { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.login-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.login-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 24px; }

.login-btn {
  width: 100%;
  padding: 13px;
  font-size: 0.95rem;
  border-radius: 10px;
  margin-top: 8px;
}

/* ── Sidebar overlay for mobile ────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 190;
}
