@import url('https://fonts.googleapis.com/css2?family=Sofia+Sans:wght@100;200;300;400;500;600;700;800;900&display=swap');
:root{--bg:#f5f7fb;--card:#fff;--text:#0f172a;--muted:#64748b;--border:#e5e7eb;--sidebar:#2b2f36;--sidebar2:#23272e;--sidebarText:#d7dee8;--primary:#0b5ed7;--primary2:#0a4fb3;--danger:#ef4444;--success:#10b981}
*{box-sizing:border-box}html,body{height:100%}body{margin:0;font-family:"Sofia Sans",sans-serif;background:var(--bg);color:var(--text)}
input,button,select,textarea{font-family:"Sofia Sans",sans-serif}a{color:inherit;text-decoration:none}img{max-width:100%}
.nav a,.nav a:visited,.nav a:hover,.nav a:active,.nav a:focus,.sidebar a,.sidebar a:visited,.sidebar a:hover,.sidebar a:active,.sidebar a:focus,.btn,.btn:visited,.btn:hover,.btn:active,.btn:focus,.actions a,.actions a:visited,.actions a:hover,.actions a:active,.actions a:focus{text-decoration:none!important}
.layout{display:flex;min-height:100vh}
.sidebar{width:260px;background:linear-gradient(180deg,var(--sidebar),var(--sidebar2));color:var(--sidebarText);position:fixed;left:0;top:0;bottom:0;padding:18px 14px;display:flex;flex-direction:column}
.brand{display:flex;align-items:center;gap:10px;padding:10px 10px 14px;border-bottom:1px solid rgba(255,255,255,.08)}
.brand .logo{width:44px;height:44px;border-radius:12px;background:rgba(255,255,255,.08);display:flex;align-items:center;justify-content:center;overflow:hidden}
.brand .logo img{width:100%;height:100%;object-fit:cover}
.brand .title{font-weight:800}.brand .subtitle{font-size:12px;opacity:.75;margin-top:2px}
.nav{margin-top:12px;overflow:auto;padding-right:6px}
.nav a{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:6px;color:var(--sidebarText);opacity:.92}
.nav a:hover{background: #343941;}
.nav a.active{background: #343941;}
.nav .group{margin:12px 10px 6px;font-size:11px;text-transform:uppercase;letter-spacing:.12em;opacity:.55}
.sidebar-bottom{margin-top:auto;padding:12px 10px 6px;border-top:1px solid rgba(255,255,255,.08);display:flex;flex-direction:column;gap:8px}
.btn-ghost{display:flex;align-items:center;justify-content:center;gap:10px;padding:10px 12px;border-radius:12px;background:rgba(255,255,255,.06);color:var(--sidebarText)}
.btn-ghost:hover{background:rgba(255,255,255,.1)}
.content{margin-left:260px;width:calc(100% - 260px);display:flex;flex-direction:column;min-height:100vh}
.topbar{height:64px;background:rgba(255,255,255,.85);backdrop-filter:blur(10px);border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;padding:0 20px;position:sticky;top:0;z-index:10}
.search{width:360px;max-width:50vw;display:flex;align-items:center;gap:10px;padding:10px 12px;background:#fff;border:1px solid var(--border);border-radius:14px}
.search input{border:0;outline:0;width:100%;font-size:14px}
.container{padding:22px 20px 40px}
.h1{font-size:26px;font-weight:850;margin:0 0 2px}.sub{color:var(--muted);margin:0 0 18px;font-size:14px}
.grid{display:grid;gap:14px}.grid.cols2{grid-template-columns:repeat(2,minmax(0,1fr))}
@media(max-width:720px){.sidebar{position:static;width:100%}.content{margin-left:0;width:100%}.search{display:none}.grid.cols2{grid-template-columns:1fr}}
.card{background:var(--card);
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .06);}
.table{width:100%;text-align:justify;border-collapse:separate;border-spacing:0;overflow:hidden;border:1px solid var(--border);border-radius:16px;background:#fff}
.table th,.table td{padding:12px 12px;border-bottom:1px solid var(--border);font-size:14px}
.table th{background:#f8fafc;font-size:12px;letter-spacing:.06em;text-transform:uppercase}
.table tr:last-child td{border-bottom:0}
.badge{display:inline-flex;align-items:center;padding:6px 10px;border-radius:999px;font-size:12px;font-weight:800;border:1px solid var(--border);background:#fff}
.badge.green{border-color:rgba(16,185,129,.25);background:rgba(16,185,129,.08);color:#047857}
.badge.gray{border-color:rgba(100,116,139,.25);background:rgba(100,116,139,.08);color:#334155}
.actions{display:flex;gap:8px;align-items:center}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:10px;border:1px solid var(--border);background:#fff;padding:10px 12px;border-radius:14px;font-weight:500;font-size:14px;cursor:pointer}
.btn.primary{background:var(--primary);border-color:var(--primary);color:#fff}
.btn.primary:hover{background:var(--primary2)}
.btn.danger{background:rgba(239,68,68,.08);border-color:rgba(239,68,68,.22);color:#b91c1c}
.btn.small{padding:8px 10px;border-radius:12px;font-size:12px}
.input,select,textarea{width:100%;border:1px solid var(--border);border-radius:14px;padding:10px 12px;font-size:14px;outline:none;background:#fff}
textarea{min-height:110px;resize:vertical}.form-row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media(max-width:720px){.form-row{grid-template-columns:1fr}}
.hr{height:1px;background:var(--border);margin:16px 0}

/* ============================
   MODAL GLOBAL (#msgOverlay)
   (ALTERADO: clean + botões à esquerda)
   ============================ */

.modal-overlay{
  position:fixed;
  inset:0;
  background:rgba(2,6,23,.55);
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:9999;
}

.modal{
  width:min(760px,100%);
  background:#fff;
  border-radius:12px;
  border:1px solid rgba(15,23,42,.10);
  box-shadow:0 18px 60px rgba(2,6,23,.35);
  overflow:hidden;
}

.modal-head{
  padding:18px 20px 12px;
  display:flex;
  align-items:center;
  gap:12px;
  border-bottom:0; /* clean */
}

.modal-icon{
  width:36px;
  height:36px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(100,116,139,.14);
  color:#334155;
  font-weight:900;
  font-size:18px;
}

.modal-title{
  font-size:22px;
  font-weight:900;
  margin:0;
  line-height:1.2;
  color:#0f172a;
}

.modal-body{
  padding:8px 20px 18px;
  color:#64748b;
  line-height:1.40;
  font-weight:350;
}

.modal-actions{
  padding:14px 20px 18px;
  display:flex;
  justify-content:flex-start; /* <-- botões à esquerda */
  gap:12px;
  border-top:1px solid #eef2f7;
}

/* Botões mais “cPanel” (sem mexer no resto do sistema) */
.modal-actions .btn{
  border-radius:4px;
  padding:10px 18px;
  font-weight:500;
}

/* Cancel/secondary fica neutro */
.modal-actions .btn[data-cancel],
.modal-actions .btn:not(.primary){
  background:#fff;
  border:1px solid #e5e7eb;
  color:#6b7280;
}

/* OK default mantém primary */
.modal-actions .btn.primary{
  background:var(--primary);
  border-color:var(--primary);
}

/* ---------- Tipos (compatível com o teu JS atual: data-type) ---------- */
.modal-overlay[data-type="danger"] .modal-icon,
.modal-overlay[data-type="error"]  .modal-icon{
  background:rgba(239,68,68,.12);
  color:#dc2626;
}
.modal-overlay[data-type="success"] .modal-icon{
  background:rgba(16,185,129,.12);
  color:#10b981;
}
.modal-overlay[data-type="warning"] .modal-icon{
  background:rgba(245,158,11,.14);
  color:#d97706;
}
.modal-overlay[data-type="confirm"] .modal-icon{
  background:rgba(100,116,139,.14);
  color:#334155;
}
.modal-overlay[data-type="info"] .modal-icon{
  background:rgba(11,94,215,.10);
  color:var(--primary);
}

/* OK vermelho em confirm/danger/error */
.modal-overlay[data-type="danger"] .modal-actions .btn.primary,
.modal-overlay[data-type="error"]  .modal-actions .btn.primary,
.modal-overlay[data-type="confirm"] .modal-actions .btn.primary{
  background:#ef4444;
  border-color:#ef4444;
}
.modal-overlay[data-type="danger"] .modal-actions .btn.primary:hover,
.modal-overlay[data-type="error"]  .modal-actions .btn.primary:hover,
.modal-overlay[data-type="confirm"] .modal-actions .btn.primary:hover{
  filter: brightness(0.95);
}

/* ---------- Preparado para data-kind (se adicionares no JS) ---------- */
.modal-overlay[data-kind="danger"] .modal-actions .btn.primary,
.modal-overlay[data-kind="error"]  .modal-actions .btn.primary,
.modal-overlay[data-kind="confirm"] .modal-actions .btn.primary{
  background:#ef4444;
  border-color:#ef4444;
}

.login-wrap{min-height:100vh;display:grid;place-items:center;background:radial-gradient(1200px 700px at 20% 10%, rgba(11,94,215,.18), transparent 60%),radial-gradient(900px 600px at 80% 30%, rgba(16,185,129,.10), transparent 60%),var(--bg)}
.login-card{width:min(460px,92vw);background:#fff;border:1px solid var(--border);border-radius:26px;padding:22px;box-shadow:0 12px 40px rgba(15,23,42,.12)}
.login-brand{display:flex;align-items:center;gap:12px;margin-bottom:14px}
.login-brand .logo{width:56px;height:56px;border-radius:16px;background:#0f172a;display:flex;align-items:center;justify-content:center;overflow:hidden}
.login-brand .logo img{width:100%;height:100%;object-fit:cover}
.login-brand .name{font-weight:950;font-size:18px}.login-brand .hint{color:var(--muted);font-size:13px;margin-top:3px}
.login-actions{display:flex;align-items:center;justify-content:space-between;margin-top:10px}
.smalllink{font-size:13px;color:var(--primary);font-weight:800}.smalllink:hover{text-decoration:underline}

/* ===== Lojas: actions icons ===== */
.store-actions{
  display:flex;
  gap:.5rem;
  justify-content:flex-end;
  align-items:center;
}

.store-icon-btn{
  width:36px;
  height:36px;
  border:1px solid #e5e7eb;
  background:#fff;
  border-radius:10px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:.15s ease;
  color:#334155;
  text-decoration:none;
}

.store-icon-btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(15,23,42,.08);
}

.store-icon-btn i{ font-size:14px; }

.store-icon-btn.danger{
  color:#dc2626;
  border-color:#fecaca;
}
.store-icon-btn.danger:hover{
  background:#fff5f5;
}

/* ===== Modal (overlay) ===== */
body.modal-open{ overflow:hidden; }

.store-modal.hidden{ display:none; }
.store-modal{
  position:fixed;
  inset:0;
  z-index:9999;
}

.store-modal-backdrop{
  position:absolute;
  inset:0;
  background:rgba(15,23,42,.55);
}

.store-modal-card{
  position:relative;
  width:min(760px, calc(100% - 24px));
  margin:48px auto;
  background:#fff;
  border-radius:16px;
  box-shadow: 0 28px 80px rgba(0,0,0,.25);
  overflow:hidden;
  animation: storePop .16s ease-out;
}

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

.store-modal-head{
  display:flex;
  gap:12px;
  align-items:flex-start;
  padding:18px 18px 14px;
  border-bottom:1px solid #eef2f7;
}

.store-modal-icon{
  width:42px;
  height:42px;
  border-radius:12px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#eef2ff;
  color:#3730a3;
  flex:0 0 auto;
}
.store-modal-icon.danger{
  background:#fff1f2;
  color:#be123c;
}

.store-modal-title{
  font-weight:900;
  font-size:16px;
  color:#0f172a;
}
.store-modal-sub{
  margin-top:2px;
  font-size:13px;
  color:#64748b;
  font-weight:700;
}

.store-modal-x{
  margin-left:auto;
  background:transparent;
  border:0;
  font-size:22px;
  line-height:1;
  color:#94a3b8;
  cursor:pointer;
  padding:2px 6px;
}
.store-modal-x:hover{ color:#334155; }

.store-modal-body{
  padding:16px 18px 18px;
}

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

@media (max-width: 720px){
  .store-grid2{ grid-template-columns: 1fr; }
  .store-modal-card{ margin:18px auto; }
}

.store-label{
  display:block;
  font-size:12px;
  color:var(--muted);
  font-weight:900;
  margin-bottom:6px;
}

.store-help{
  font-size:12px;
  color:#94a3b8;
  font-weight:700;
  margin-top:6px;
}

.store-check{
  display:flex;
  gap:10px;
  align-items:center;
  font-size:13px;
  color:var(--muted);
  font-weight:800;
}
.store-check input{ width:16px; height:16px; }

.store-modal-foot{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding-top:12px;
  border-top:1px solid #eef2f7;
  margin-top:14px;
}

.store-warning{
  padding:12px 12px;
  border-radius:12px;
  background:#fff7ed;
  border:1px solid #fed7aa;
  color:#9a3412;
  font-weight:800;
}

/* Danger button (se não existir no teu app.css) */
.btn.danger{
  background:#dc2626;
  color:#fff;
  border:1px solid #dc2626;
}
.btn.danger:hover{ filter: brightness(0.95); }

/* ===== Scrollbar moderna e discreta ===== */

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: #292d34;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background-color .2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background-color: #292d34;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #292d34 transparent;
}
/* Submenu Apps */
.nav-sub .sub{ display:none; margin-left:12px; margin-top:6px; }
.nav-sub.open .sub{ display:block; }

.nav-sub > a{
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.nav-sub .caret{
  opacity:.55;
  font-size:12px;
  transition:transform .2s ease, opacity .2s ease;
}

.nav-sub.open .caret{
  transform:rotate(180deg);
  opacity:.8;
}

/* Sub items look */
.nav-sub .sub a{
  display:block;
  padding:8px 10px;
  border-radius:10px;
  font-size:14px;
  opacity:.5;
  font-weight: 400;
}

/* ===== Submenu com linha tracejada ===== */
.nav-sub{
  position: relative;
}

.nav-sub .sub{
  position: relative;
  margin-left: 14px;
  padding-left: 14px;
}

/* Linha tracejada vertical */
.nav-sub .sub::before{
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  border-left: 1px dashed rgba(255,255,255,.15);
}

/* Item ativo do submenu */
.nav-sub .sub a.active{
  background: #343941;
  font-weight: 500;
  opacity: 1;
}

/* X (fechar) alinhado à direita no modal */
.modal-head button{
  margin-left:auto;            /* <<< ISTO empurra para a direita */
  width:32px;
  height:32px;
  border-radius:8px;
  border:1px solid #e5e7eb;
  background:#fff;
  color:#64748b;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight: 300;
    line-height: 1;
    font-size: 32px;
}

.modal-head button:hover{
  background:#f8fafc;
  color:#334155;
}

/* OK verde quando for success */
.modal-overlay[data-type="success"] .modal-actions .btn.primary{
  background:#10b981;
  border-color:#10b981;
}
.modal-overlay[data-type="success"] .modal-actions .btn.primary:hover{
  filter: brightness(0.95);
}

/* =========================================================
   MODAL (scroll interno, header/footer fixos)
   ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;   /* 👈 SCROLL AQUI */
}

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: #fff;
}
/* =========================================================
   CLIENT MODAL (Novo/Editar Cliente) — sem conflito com #msgOverlay
   ========================================================= */
.client-modal.hidden{ display:none; }
.client-modal{
  position:fixed;
  inset:0;
  z-index:9999;
}

.client-modal-backdrop{
  position:absolute;
  inset:0;
  background:rgba(15,23,42,.55);
  backdrop-filter: blur(2px);
}

.client-modal-card{
  position:relative;
  width:min(820px, calc(100% - 24px));
  margin:40px auto;
  background:#fff;
  border-radius:16px;
  box-shadow:0 28px 80px rgba(0,0,0,.25);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  max-height: calc(100vh - 80px); /* ✅ limita ao ecrã */
}

@media (max-width:720px){
  .client-modal-card{ margin:16px auto; max-height: calc(100vh - 32px); }
}

.client-modal-head{
  padding:18px 18px 14px;
  border-bottom:1px solid #eef2f7;
  display:flex;
  gap:12px;
  align-items:flex-start;
}

.client-modal-title{ font-weight:900; font-size:18px; color:#0f172a; }
.client-modal-sub{ margin-top:2px; font-size:13px; color:#64748b; font-weight:700; }

.client-modal-x{
  margin-left:auto;
  background:transparent;
  border:0;
  font-size:26px;
  line-height:1;
  color:#94a3b8;
  cursor:pointer;
  padding:2px 6px;
}
.client-modal-x:hover{ color:#334155; }

/* ✅ AQUI está o scroll */
.client-modal-body{
  padding:16px 18px 18px;
  overflow-y:auto;
}

.client-modal-foot{
  border-top:1px solid #eef2f7;
  padding:12px 18px 14px;
  display:flex;
  justify-content:flex-end;
  gap:10px;
  background:#fff;
}
/* =========================================================
   XMODAL (Clientes) — scroll interno garantido
   ========================================================= */
.xmodal{
  position:fixed;
  inset:0;
  z-index:9999;
  display:none;                 /* abre via JS: display:flex */
  align-items:center;
  justify-content:center;
  padding:18px;
}

.xmodal[aria-hidden="false"]{ display:flex; }

.xmodal-backdrop{
  position:absolute;
  inset:0;
  background:rgba(15,23,42,.55);
  backdrop-filter: blur(2px);
}

.xmodal-dialog{
  position:relative;
  width:min(820px, 100%);
  background:#fff;
  border-radius:16px;
  box-shadow:0 28px 80px rgba(0,0,0,.25);
  overflow:hidden;

  display:flex;                 /* ✅ necessário */
  flex-direction:column;        /* ✅ necessário */

  max-height: calc(90vh - 36px); /* ✅ limita no ecrã */
}

@media (max-width:720px){
  .xmodal{ padding:12px; }
  .xmodal-dialog{ max-height: calc(100vh - 24px); }
}

.xmodal-head{
  padding:18px 18px 14px;
  border-bottom:1px solid #eef2f7;
  display:flex;
  align-items:flex-start;
  gap:12px;
}

.xmodal-head-left{ display:flex; gap:12px; align-items:flex-start; }

.xmodal-body{
  padding:16px 18px 18px;
  overflow-y:auto;              /* ✅ SCROLL AQUI */
  -webkit-overflow-scrolling: touch;
}

.xmodal-foot{
  padding:12px 18px 14px;
  border-top:1px solid #eef2f7;
  display:flex;
  justify-content:flex-end;
  gap:10px;
  background:#fff;
}

.xmodal-x{
  margin-left:auto;
  background:transparent;
  border:0;
  font-size:26px;
  line-height:1;
  color:#94a3b8;
  cursor:pointer;
  padding:2px 6px;
}
.xmodal-x:hover{ color:#334155; }
