/* ============================================================
   NATAN BARBEARIA — Sistema de Gestão
   Design tokens + base styles
   ============================================================ */

:root {
  /* Surfaces — warm near-black */
  --bg: #0c0c0e;
  --bg-grain: #0e0e11;
  --surface: #151518;
  --surface-2: #1c1c21;
  --surface-3: #232329;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);

  /* Brand — brass / gold */
  --gold: #c9a25a;
  --gold-bright: #e3c279;
  --gold-deep: #8f6f37;
  --gold-soft: rgba(201, 162, 90, 0.14);
  --gold-line: rgba(201, 162, 90, 0.32);

  /* Text */
  --text: #f3efe7;
  --text-dim: #a39d92;
  --text-faint: #6c675f;

  /* Status */
  --green: #5fae7e;
  --green-soft: rgba(95, 174, 126, 0.15);
  --red: #d9645c;
  --red-soft: rgba(217, 100, 92, 0.15);
  --blue: #6a93c4;
  --blue-soft: rgba(106, 147, 196, 0.15);
  --amber: #d8a24a;
  --amber-soft: rgba(216, 162, 74, 0.15);

  /* Geometry */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.55);

  --sidebar-w: 248px;
  --font-display: 'Oswald', sans-serif;
  --font-ui: 'Archivo', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

img { max-width: 100%; }

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

#root { height: 100vh; }

/* subtle texture on the app background */
.app-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(201, 162, 90, 0.06), transparent 60%),
    radial-gradient(900px 700px at -5% 110%, rgba(201, 162, 90, 0.04), transparent 55%),
    var(--bg);
  z-index: -1;
}

::selection { background: var(--gold-soft); color: var(--gold-bright); }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: #34343c; background-clip: padding-box; }

/* ---------- Typography helpers ---------- */
.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.eyebrow {
  font-family: var(--font-display);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 11px;
  color: var(--gold);
}
.num { font-variant-numeric: tabular-nums; }

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ---- Sidebar (desktop) ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #121215, #0e0e10);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 20px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--gold-bright), var(--gold-deep));
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(201, 162, 90, 0.25), inset 0 1px 0 rgba(255,255,255,0.35);
  position: relative;
}
.brand-mark span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: #1a1407;
}
.brand-text { line-height: 1.05; }
.brand-text .name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.brand-text .sub {
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-family: var(--font-display);
}

.nav-group { margin-top: 14px; }
.nav-group-label {
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--text-faint); padding: 0 12px 8px; font-family: var(--font-display);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: border-color .15s;
  position: relative;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--gold-soft);
  color: var(--gold-bright);
  border-color: var(--gold-line);
}
.nav-item.active::before {
  content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px; background: var(--gold);
}
.nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: #1a1407;
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 20px;
  font-variant-numeric: tabular-nums;
}

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-md);
  cursor: pointer;
}
.user-chip:hover { background: var(--surface); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-3);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 600;
  color: var(--gold-bright); flex-shrink: 0;
  border: 1px solid var(--border-strong);
  font-size: 14px;
  overflow: hidden;
}
.user-chip .meta { line-height: 1.15; min-width: 0; }
.user-chip .meta .n { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta .r { font-size: 11px; color: var(--text-faint); }

/* ---- Main column ---- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  height: 66px; flex-shrink: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(12,12,14,0.7);
  backdrop-filter: blur(12px);
}
.page-title { line-height: 1.1; }
.page-title h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 22px; letter-spacing: 0.02em; text-transform: uppercase;
}
.page-title .crumb { font-size: 12px; color: var(--text-faint); letter-spacing: 0.04em; }

.search {
  margin-left: auto;
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 30px; padding: 8px 15px;
  width: 260px; color: var(--text-dim);
}
.search input { background: none; border: none; outline: none; color: var(--text); width: 100%; font-family: var(--font-ui); font-size: 14px; }
.search input::placeholder { color: var(--text-faint); }
.search svg { width: 17px; height: 17px; flex-shrink: 0; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; position: relative;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--gold); border: 2px solid var(--surface);
}

.content { flex: 1; overflow-y: auto; padding: 26px; }
.content-inner { max-width: 1240px; margin: 0 auto; }

/* ---- Mobile top bar + bottom nav (hidden on desktop) ---- */
.mobile-top, .bottom-nav, .mobile-menu-overlay { display: none; }

/* ============================================================
   PRIMITIVES
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  position: relative;
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 {
  font-family: var(--font-display); font-weight: 600; font-size: 16px;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.card-head .sub { font-size: 12.5px; color: var(--text-faint); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 11px;
  font-family: var(--font-ui); font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer;
  white-space: nowrap; transition: filter .15s, background .15s, border-color .15s;
}
.btn svg { width: 17px; height: 17px; }
.btn-gold { background: linear-gradient(160deg, var(--gold-bright), var(--gold)); color: #1a1407; box-shadow: 0 6px 18px rgba(201,162,90,0.22); }
.btn-gold:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-line { background: transparent; color: var(--text-dim); border-color: var(--border-strong); }
.btn-line:hover { color: var(--text); border-color: var(--gold-line); }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; }
.btn-icon-only { padding: 9px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 30px;
  font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim);
}
.chip-dot { width: 7px; height: 7px; border-radius: 50%; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 7px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
}
.badge .b-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-gold { background: var(--gold-soft); color: var(--gold-bright); }
.badge-mute { background: var(--surface-2); color: var(--text-faint); }

/* Stat card */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 20px;
  position: relative; overflow: hidden;
}
.stat-ico {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; margin-bottom: 14px;
}
.stat-ico svg { width: 20px; height: 20px; }
.stat-label { font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px; letter-spacing: .02em; }
.stat-value { font-family: var(--font-display); font-weight: 600; font-size: 30px; line-height: 1; letter-spacing: 0.01em; }
.stat-value .cur { font-size: 17px; color: var(--text-dim); margin-right: 2px; }
.stat-trend { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; margin-top: 10px; }
.stat-trend svg { width: 14px; height: 14px; }
.trend-up { color: var(--green); }
.trend-down { color: var(--red); }

/* Grids */
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* Table */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600; padding: 12px 16px;
  border-bottom: 1px solid var(--border); font-family: var(--font-display);
}
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; }

.list-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
  color: var(--gold-bright); background: var(--surface-3);
  border: 1px solid var(--border-strong); overflow: hidden;
}

.divider { height: 1px; background: var(--border); margin: 0; border: none; }

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

/* segmented control */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.segmented button {
  border: none; background: none; color: var(--text-dim); cursor: pointer;
  padding: 6px 14px; border-radius: 7px; font-family: var(--font-ui); font-weight: 600; font-size: 13px;
}
.segmented button.on { background: var(--surface-3); color: var(--text); }

/* progress */
.bar { height: 8px; border-radius: 20px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright)); }

/* Modal / sheet */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-xl); width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
  animation: pop .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes pop { from { transform: translateY(14px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 19px; text-transform: uppercase; letter-spacing: .02em; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* form */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px; letter-spacing: .02em; }
.input, .select, textarea.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 11px 13px; color: var(--text); font-family: var(--font-ui); font-size: 14.5px; outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--gold-line); }
.input::placeholder { color: var(--text-faint); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a39d92' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 36px; }

.fade-in { animation: fadein .32s ease both; }
@keyframes fadein { from { transform: translateY(9px); } to { transform: none; } }

/* section title row */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.stack-gap > * + * { margin-top: 16px; }

/* ============================================================
   RESPONSIVE — tablet & mobile
   ============================================================ */
@media (max-width: 1080px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .sidebar { display: none; }
  body { font-size: 14.5px; }

  /* Mobile top bar */
  .mobile-top {
    display: flex; align-items: center; gap: 12px;
    height: 58px; flex-shrink: 0; padding: 0 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(12,12,14,0.85); backdrop-filter: blur(12px);
    position: sticky; top: 0; z-index: 40;
  }
  .topbar { display: none; }
  .content { padding: 16px; padding-bottom: 92px; }

  .mobile-top .brand-mark { width: 34px; height: 34px; }
  .mobile-top .brand-mark span { font-size: 18px; }
  .mobile-top .mt-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; text-transform: uppercase; letter-spacing: .03em; }

  /* Bottom nav */
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    height: 68px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(16,16,19,0.92); backdrop-filter: blur(16px);
    border-top: 1px solid var(--border); z-index: 50;
    justify-content: space-around; align-items: stretch;
  }
  .bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-faint); cursor: pointer; border-radius: 12px; position: relative;
    font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  }
  .bn-item svg { width: 22px; height: 22px; }
  .bn-item.active { color: var(--gold-bright); }
  .bn-item.active svg { filter: drop-shadow(0 0 8px rgba(201,162,90,.4)); }
  .bn-more-badge { position: absolute; top: 4px; right: 50%; transform: translateX(16px); width: 7px; height: 7px; background: var(--gold); border-radius: 50%; }

  /* Slide-up full menu */
  .mobile-menu-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 60; animation: fade .2s ease; }
  .mobile-menu {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
    background: var(--surface); border-top-left-radius: 22px; border-top-right-radius: 22px;
    border-top: 1px solid var(--border-strong); padding: 12px 14px calc(20px + env(safe-area-inset-bottom));
    max-height: 82vh; overflow-y: auto; animation: sheetup .26s cubic-bezier(.2,.8,.3,1);
  }
  @keyframes sheetup { from { transform: translateY(100%); } }
  .mobile-menu .grabber { width: 40px; height: 4px; border-radius: 4px; background: var(--surface-3); margin: 6px auto 14px; }
  .mm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .mm-item {
    display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
    color: var(--text-dim); cursor: pointer; font-size: 12px; font-weight: 600; text-align: center;
  }
  .mm-item svg { width: 22px; height: 22px; }
  .mm-item.active { background: var(--gold-soft); color: var(--gold-bright); border-color: var(--gold-line); }

  /* colapsa qualquer grid (inclusive os com colunas definidas inline) em 1 coluna;
     .keep-cols preserva as colunas (grids pequenos, ex.: mini-stats) */
  .grid:not(.keep-cols) { grid-template-columns: 1fr !important; }
  .stat-value { font-size: 26px; }
  .content { overflow-x: hidden; }
  .search { display: none; }
  .modal { max-width: 100%; border-radius: 20px; }
  .overlay { padding: 0; align-items: flex-end; }
  .modal { border-bottom-left-radius: 0; border-bottom-right-radius: 0; max-height: 92vh; animation: sheetup .26s cubic-bezier(.2,.8,.3,1); }

  /* tables scroll horizontally */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 540px; }
  .content-inner { max-width: 100%; }
}

/* hide scrollbar utility for horizontal chip rows */
.hscroll { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
.hscroll::-webkit-scrollbar { display: none; }
