/* ============================================================================
   MIKE DEVELOPMENT — Design System  v2 (Mobile-First Responsive)
   ============================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── TOKENS ─────────────────────────────────────────────────────────────── */
:root {
  /* superfícies */
  --bg:   #0a0b0f;
  --s1:   #101218;
  --s2:   #161922;
  --s3:   #1d212c;
  --s4:   #252a37;
  /* bordas */
  --bd:   rgba(255,255,255,.07);
  --bd2:  rgba(255,255,255,.12);
  --bd3:  rgba(255,255,255,.20);
  /* texto */
  --tx:   #eef1f6;
  --tx2:  #9aa3b2;
  --tx3:  #5d6675;
  /* marca */
  --pri:       #3b6fe0;
  --pri2:      #5b8cff;
  --pri-soft:  rgba(59,111,224,.14);
  --pri-bd:    rgba(91,140,255,.35);
  --grad:      linear-gradient(135deg,#3b6fe0,#5b8cff);
  /* estados */
  --ok:       #10c982; --ok-soft:  rgba(16,201,130,.12); --ok-bd:   rgba(16,201,130,.30);
  --warn:     #f5a623; --warn-soft:rgba(245,166,35,.12);  --warn-bd: rgba(245,166,35,.30);
  --err:      #e0485a; --err-soft: rgba(224,72,90,.12);   --err-bd:  rgba(224,72,90,.35);
  --wa:       #25D366; --wa-soft:  rgba(37,211,102,.12);  --wa-bd:   rgba(37,211,102,.30);
  /* raios */
  --r:  14px;
  --rs: 10px;
  --rx: 8px;
  /* sombras */
  --sh:    0 10px 40px rgba(0,0,0,.50);
  --sh-sm: 0 4px 16px rgba(0,0,0,.35);
  /* fonte */
  --ff: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* espaçamento fluido */
  --gutter: 16px;
  --gap:    12px;
}

/* ── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html { scroll-behavior: smooth; }
body {
  font-family: var(--ff);
  background: var(--bg);
  color: var(--tx);
  min-height: 100vh;
  min-height: 100dvh;          /* dvh para mobile (barra de endereços) */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11','ss01';
  letter-spacing: -.01em;
  overflow-x: hidden;          /* evita scroll horizontal global */
}
a { color: inherit; text-decoration: none; }
img, video, svg { max-width: 100%; display: block; }
::selection { background: var(--pri-soft); }

/* scrollbar — desktop only */
@media (pointer: fine) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--s4); border-radius: 8px; border: 2px solid var(--bg); }
  ::-webkit-scrollbar-thumb:hover { background: var(--bd3); }
}

/* ── TIPOGRAFIA ─────────────────────────────────────────────────────────── */
.h1   { font-size: clamp(20px, 5vw, 26px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.h2   { font-size: clamp(16px, 4vw, 19px); font-weight: 700; letter-spacing: -.02em; }
.h3   { font-size: 15px; font-weight: 700; }
.muted  { color: var(--tx2); }
.tiny   { font-size: 12px; color: var(--tx3); }
.eyebrow{ font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--tx3); }

/* ── BOTÕES ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  border: none;
  cursor: pointer;
  border-radius: var(--rs);
  padding: 10px 16px;
  transition: transform .12s, filter .15s, background .15s, border-color .15s;
  white-space: nowrap;
  line-height: 1;
  /* toque mínimo 44 px (WCAG 2.5.5) */
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:active { transform: translateY(1px); }

.btn-pri    { background: var(--grad); color: #fff; box-shadow: 0 4px 16px var(--pri-bd); }
.btn-pri:hover { filter: brightness(1.08); }
.btn-ghost  { background: var(--s2); color: var(--tx2); border: 1px solid var(--bd); }
.btn-ghost:hover { background: var(--s3); color: var(--tx); border-color: var(--bd2); }
.btn-soft   { background: var(--pri-soft); color: var(--pri2); border: 1px solid var(--pri-bd); }
.btn-soft:hover { background: var(--pri-bd); color: #fff; }
.btn-wa     { background: var(--wa); color: #04210f; }
.btn-wa:hover { filter: brightness(1.08); }
.btn-danger { background: var(--err-soft); color: var(--err); border: 1px solid var(--err-bd); }
.btn-danger:hover { background: var(--err); color: #fff; }

.btn-sm  { padding: 8px 13px; font-size: 12.5px; min-height: 36px; }
.btn-lg  { padding: 13px 22px; font-size: 14.5px; }
.btn-fw  { width: 100%; }
.btn-icon{ padding: 9px; width: 44px; height: 44px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ícone compacto (linhas de tabela) */
.ibtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;                /* 36 mínimo em tabela */
  border-radius: var(--rx);
  background: var(--s2); border: 1px solid var(--bd); color: var(--tx2);
  cursor: pointer; transition: .13s;
  touch-action: manipulation;
}
.ibtn svg { width: 15px; height: 15px; }
.ibtn:hover { background: var(--s3); color: var(--tx); border-color: var(--bd2); }
.ibtn.danger:hover { background: var(--err-soft); color: var(--err); border-color: var(--err-bd); }
.ibtn.wa:hover    { background: var(--wa-soft);  color: var(--wa);  border-color: var(--wa-bd);  }

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--s1);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  padding: 16px;                /* 20px → 16px base; sobe em telas maiores */
  width: 100%;
  min-width: 0;                 /* evita overflow em flex/grid */
}
.card-pad-0 { padding: 0; overflow: hidden; }

@media (min-width: 480px) {
  .card { padding: 20px; }
}

/* ── FORM ───────────────────────────────────────────────────────────────── */
.field    { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.label    { font-size: 12.5px; font-weight: 600; color: var(--tx2); letter-spacing: -.01em; }
.req      { color: var(--pri2); }

.input, .select, .textarea {
  width: 100%;
  background: var(--s2);
  border: 1px solid var(--bd2);
  border-radius: var(--rs);
  color: var(--tx);
  font-family: inherit;
  font-size: 16px;              /* 16px evita zoom automático no iOS */
  padding: 11px 14px;
  transition: .15s;
  outline: none;
  min-height: 44px;
}
.input::placeholder,
.textarea::placeholder { color: var(--tx3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 3px var(--pri-soft);
}
.input.err, .select.err { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

/* grids de formulário — coluna única em mobile, 2/3 col em telas maiores */
.row2 { display: grid; grid-template-columns: 1fr; gap: 0; }
.row3 { display: grid; grid-template-columns: 1fr; gap: 0; }

@media (min-width: 480px) {
  .row2 { grid-template-columns: 1fr 1fr; gap: 14px; }
}
@media (min-width: 640px) {
  .row3 { grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
}

.errline       { font-size: 12px; color: var(--err); font-weight: 500; display: none; }
.errline.show  { display: block; }

/* ── BADGES / TAGS ──────────────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; letter-spacing: -.01em;
  white-space: nowrap;
}
.tag-pri  { background: var(--pri-soft); color: var(--pri2);  }
.tag-ok   { background: var(--ok-soft);  color: var(--ok);    }
.tag-warn { background: var(--warn-soft);color: var(--warn);  }
.tag-err  { background: var(--err-soft); color: var(--err);   }
.tag-gray { background: var(--s3);       color: var(--tx2);   }
.tag-wa   { background: var(--wa-soft);  color: var(--wa);    }

/* ── TABELA ─────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--bd);
  border-radius: var(--r);
  background: var(--s1);
  width: 100%;
  max-width: 100%;
}
table.tbl {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;             /* garante scroll horizontal em mobile */
}
.tbl th {
  font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--tx3); text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--bd);
  background: var(--s2); white-space: nowrap;
}
.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bd);
  font-size: 13.5px;
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--s2); }
.td-strong { font-weight: 600; color: var(--tx); }
.td-sub    { font-size: 12px; color: var(--tx3); margin-top: 2px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── STAT CARDS ─────────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2 col em mobile */
  gap: var(--gap);
}
@media (min-width: 480px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

.stat {
  background: var(--s1);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  padding: 16px;
  position: relative; overflow: hidden;
  min-width: 0;
}
.stat::after {
  content: ''; position: absolute; inset: 0;
  opacity: .04; background: var(--grad); pointer-events: none;
}
.stat-ico {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--pri-soft); color: var(--pri2); margin-bottom: 10px;
}
.stat-ico svg { width: 18px; height: 18px; }
.stat-ico.ok   { background: var(--ok-soft);   color: var(--ok);   }
.stat-ico.warn { background: var(--warn-soft);  color: var(--warn); }
.stat-ico.wa   { background: var(--wa-soft);    color: var(--wa);   }

.stat-num { font-size: clamp(22px, 5vw, 28px); font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat-lbl { font-size: 12px; color: var(--tx2); margin-top: 4px; font-weight: 500; }

/* ── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 24px; color: var(--tx3); }
.empty svg { width: 44px; height: 44px; opacity: .4; margin: 0 auto 14px; }
.empty h3  { font-size: 16px; font-weight: 700; color: var(--tx2); margin-bottom: 5px; }
.empty p   { font-size: 13.5px; }

/* ── SEARCH ─────────────────────────────────────────────────────────────── */
.search { position: relative; flex: 1; width: 100%; max-width: 360px; }
.search svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--tx3); pointer-events: none;
}
.search input {
  width: 100%;
  background: var(--s2); border: 1px solid var(--bd2); border-radius: var(--rs);
  color: var(--tx); font-family: inherit;
  font-size: 16px;              /* evita zoom iOS */
  padding: 11px 14px 11px 40px;
  outline: none; transition: .15s;
  min-height: 44px;
}
.search input:focus { border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-soft); }
.search input::placeholder { color: var(--tx3); }

/* ── PAGE HEADER ────────────────────────────────────────────────────────── */
.page-head {
  display: flex;
  flex-direction: column;       /* empilha em mobile */
  gap: 12px;
  margin-bottom: 20px;
}
.page-head .actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
}
.page-head .sub { color: var(--tx3); font-size: 13px; margin-top: 3px; }

@media (min-width: 600px) {
  .page-head {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 24px;
  }
}

/* ── MODAL ──────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
  display: none; align-items: flex-end; /* sheet bottom em mobile */
  justify-content: center;
  padding: 0;
  overflow-y: auto;
}
.overlay.open { display: flex; }

.modal {
  background: var(--s1);
  border: 1px solid var(--bd2);
  /* sheet completa em mobile */
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: var(--sh);
  animation: modalIn .22s cubic-bezier(.34,1.3,.64,1);
}

/* desktop — modal flutuante centralizado */
@media (min-width: 600px) {
  .overlay { align-items: flex-start; padding: 28px 18px; }
  .modal {
    border-radius: 18px;
    max-width: 560px;
    max-height: none;
    margin: auto;
  }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.97) translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.modal-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--bd);
  position: sticky; top: 0; background: var(--s1); z-index: 1;
}
.modal-hd .h2 { margin: 0; }
.modal-bd { padding: 20px; }
.modal-ft {
  display: flex; justify-content: flex-end; flex-wrap: wrap;
  gap: 10px; padding: 16px 20px;
  border-top: 1px solid var(--bd);
  position: sticky; bottom: 0; background: var(--s1);
}

/* botões de modal ocupam full-width em mobile */
@media (max-width: 480px) {
  .modal-ft { flex-direction: column; }
  .modal-ft .btn { width: 100%; }
}

@media (min-width: 480px) {
  .modal-hd { padding: 20px 24px; }
  .modal-bd { padding: 24px; }
  .modal-ft { padding: 18px 24px; }
}

.modal-x {
  width: 34px; height: 34px; border-radius: var(--rx);
  background: var(--s2); border: 1px solid var(--bd);
  color: var(--tx2); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: .13s; flex-shrink: 0;
}
.modal-x:hover { background: var(--s3); color: var(--tx); }
.modal-x svg { width: 15px; height: 15px; }

.fsec {
  font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--pri2); margin: 22px 0 14px;
  padding-bottom: 8px; border-bottom: 1px solid var(--bd);
}
.fsec:first-child { margin-top: 0; }

/* bloco repetível */
.block {
  background: var(--s2); border: 1px solid var(--bd);
  border-radius: var(--r); padding: 16px; margin-bottom: 12px;
  min-width: 0;
}
.block-hd {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 8px;
}
.block-hd .t       { font-size: 13px; font-weight: 700; color: var(--pri2); }
.block-hd .t.green { color: var(--ok); }

.add-block {
  width: 100%; border: 1.5px dashed var(--bd2); background: transparent;
  color: var(--tx2); border-radius: var(--rs); padding: 11px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 8px; transition: .15s;
  margin-bottom: 6px; min-height: 44px;
}
.add-block:hover { border-color: var(--pri); color: var(--pri2); background: var(--pri-soft); }
.add-block svg { width: 15px; height: 15px; }

/* ── TOAST ──────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; bottom: env(safe-area-inset-bottom, 16px);
  left: 50%; transform: translateX(-50%); z-index: 300;
  display: flex; flex-direction: column; gap: 10px;
  align-items: center; width: calc(100vw - 32px); max-width: 480px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--s3); border: 1px solid var(--bd2);
  border-radius: var(--rs); padding: 13px 16px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--sh); animation: toastIn .3s ease;
  width: 100%;
}
.toast svg { width: 17px; height: 17px; flex-shrink: 0; }
.toast.ok   { border-color: var(--ok-bd);   } .toast.ok   svg { color: var(--ok);   }
.toast.err  { border-color: var(--err-bd);  } .toast.err  svg { color: var(--err);  }
.toast.warn { border-color: var(--warn-bd); } .toast.warn svg { color: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ── LOADER ─────────────────────────────────────────────────────────────── */
.loader {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(10,11,15,.72); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
}
.loader.show { display: flex; }
.spinner {
  width: 42px; height: 42px;
  border: 3px solid var(--bd2); border-top-color: var(--pri2);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SYNC PILL ──────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  padding: 5px 11px; border-radius: 20px;
  background: var(--s2); border: 1px solid var(--bd); color: var(--tx3);
  white-space: nowrap;
}
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--tx3); flex-shrink: 0; }
.pill.ok      { color: var(--ok);   border-color: var(--ok-bd);   } .pill.ok::before   { background: var(--ok);   }
.pill.err     { color: var(--warn); border-color: var(--warn-bd); } .pill.err::before  { background: var(--warn); }
.pill.loading { color: var(--pri2); border-color: var(--pri-bd);  } .pill.loading::before { background: var(--pri2); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ── UTILITÁRIOS ────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* safe area para iphones (notch / home bar) */
.safe-top    { padding-top: env(safe-area-inset-top, 0px); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* contentor de página */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* helpers de stack / cluster */
.stack  { display: flex; flex-direction: column; gap: var(--gap); }
.cluster{ display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* grid genérico responsivo */
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: minmax(0,1fr); gap: var(--gap); }
.grid-4 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--gap); }

@media (min-width: 480px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (min-width: 640px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (min-width: 768px) {
  .grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
}

/* seção com divisor */
.divider { border: none; border-top: 1px solid var(--bd); margin: 20px 0; }

/* texto truncado em 1 linha */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }