/* ==========================================================================
   Prodata POS Manager — sistema visual do portal
   Ferramenta de operação: densa, escaneável, com estado legível de relance.
   ========================================================================== */

:root {
  color-scheme: light;

  --bg:          #eceff0;
  --surface:     #ffffff;
  --surface-2:   #f4f7f6;
  --surface-3:   #e9eeec;

  --ink:         #101614;
  --ink-2:       #3a4642;
  --muted:       #6d7b76;

  --line:        #dbe2df;
  --line-strong: #b9c5c0;

  --accent:      #0b7a55;
  --accent-ink:  #ffffff;
  --accent-soft: #dcede5;

  --ok:          #0b7a55;
  --ok-soft:     #dcede5;
  --warn:        #8a5a06;
  --warn-soft:   #f7ecd6;
  --danger:      #a8352b;
  --danger-soft: #f7e2df;
  --idle-soft:   #e6eaea;

  --sidebar-bg:   #14201c;
  --sidebar-ink:  #cfdbd6;
  --sidebar-ink2: #8ca096;
  --sidebar-line: #24332e;

  --radius:  6px;
  --shadow:  0 1px 2px rgba(16, 22, 20, .06), 0 4px 12px rgba(16, 22, 20, .04);
  --sidebar-w: 244px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg:          #0c1210;
    --surface:     #141c19;
    --surface-2:   #1a2320;
    --surface-3:   #212c28;

    --ink:         #e7edea;
    --ink-2:       #b6c3bd;
    --muted:       #83938c;

    --line:        #253029;
    --line-strong: #37463f;

    --accent:      #43c494;
    --accent-ink:  #06231a;
    --accent-soft: #16332a;

    --ok:          #43c494;
    --ok-soft:     #16332a;
    --warn:        #d9a441;
    --warn-soft:   #33280f;
    --danger:      #e0796c;
    --danger-soft: #351a17;
    --idle-soft:   #222c29;

    --sidebar-bg:   #0e1614;
    --sidebar-ink:  #c3d1cb;
    --sidebar-ink2: #74867e;
    --sidebar-line: #1d2a25;

    --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:#0c1210; --surface:#141c19; --surface-2:#1a2320; --surface-3:#212c28;
  --ink:#e7edea; --ink-2:#b6c3bd; --muted:#83938c;
  --line:#253029; --line-strong:#37463f;
  --accent:#43c494; --accent-ink:#06231a; --accent-soft:#16332a;
  --ok:#43c494; --ok-soft:#16332a; --warn:#d9a441; --warn-soft:#33280f;
  --danger:#e0796c; --danger-soft:#351a17; --idle-soft:#222c29;
  --sidebar-bg:#0e1614; --sidebar-ink:#c3d1cb; --sidebar-ink2:#74867e; --sidebar-line:#1d2a25;
  --shadow: 0 1px 2px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: Consolas, "SF Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .84em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- shell ---------------------------------------------------- */

.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--sidebar-line);
}

.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  color: #fff; text-decoration: none;
  border-bottom: 1px solid var(--sidebar-line);
}
.sidebar .brand .mark {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.sidebar .brand b { font-size: .95rem; font-weight: 600; letter-spacing: -.01em; display: block; line-height: 1.2; }
.sidebar .brand span { font-size: .72rem; color: var(--sidebar-ink2); }

.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav .group {
  font-size: .66rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--sidebar-ink2); padding: 14px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius);
  color: var(--sidebar-ink); text-decoration: none;
  font-size: .9rem; border-left: 2px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.08); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a.active svg { opacity: 1; color: var(--accent); }
.nav .count {
  margin-left: auto; background: var(--accent); color: var(--accent-ink);
  font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 20px;
  font-variant-numeric: tabular-nums;
}

.sidebar .foot { border-top: 1px solid var(--sidebar-line); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.sidebar .foot .who { min-width: 0; flex: 1; }
.sidebar .foot .who b { display: block; font-size: .82rem; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .foot .who span { font-size: .7rem; color: var(--sidebar-ink2); }
.sidebar .foot button, .sidebar .foot .iconbtn {
  background: transparent; border: 1px solid var(--sidebar-line); color: var(--sidebar-ink);
  border-radius: var(--radius); padding: 5px 7px; cursor: pointer; display: grid; place-items: center;
}
.sidebar .foot button:hover { background: rgba(255,255,255,.07); }
.sidebar .foot form { display: contents; }

/* ---------- área de conteúdo ------------------------------------------ */

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px; height: 58px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.06rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.topbar .crumb { color: var(--muted); font-size: .84rem; }
.topbar .crumb a { color: var(--muted); }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.menu-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; cursor: pointer; color: var(--ink); }

.content { padding: 22px 26px 64px; max-width: 1280px; width: 100%; }

section.block { margin-bottom: 26px; }
section.block > h2 {
  font-size: .78rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 10px; font-weight: 600;
}

/* ---------- cartões e métricas ---------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > header { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card > header h3 { margin: 0; font-size: .92rem; font-weight: 600; }
.card > header .actions { margin-left: auto; display: flex; gap: 8px; }
.card .body { padding: 16px; }
.card .body.tight { padding: 0; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; box-shadow: var(--shadow);
}
.metric .label { font-size: .7rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.metric .value { font-size: 1.7rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric .hint { font-size: .78rem; color: var(--muted); }
.metric.attention { border-color: var(--warn); }
.metric.attention .value { color: var(--warn); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; align-items: start; }

/* ---------- tabelas ---------------------------------------------------- */

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 9px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th {
  font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--line-strong);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.tight { width: 1%; white-space: nowrap; }

/* ---------- estado ----------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 20px;
  border: 1px solid transparent; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.active   { color: var(--ok);     background: var(--ok-soft); }
.pill.pending  { color: var(--warn);   background: var(--warn-soft); }
.pill.blocked  { color: var(--danger); background: var(--danger-soft); }
.pill.retired  { color: var(--muted);  background: var(--idle-soft); }
.pill.plain    { color: var(--muted);  background: var(--idle-soft); }
.pill.plain::before { display: none; }

.dot-ok   { color: var(--ok); }
.dot-warn { color: var(--warn); }
.dot-bad  { color: var(--danger); }

/* ---------- formulários ------------------------------------------------ */

form { display: flex; flex-direction: column; gap: 14px; }
form.inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; gap: 10px; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.fields.one { grid-template-columns: 1fr; }

label { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; font-weight: 600; color: var(--ink-2); }
label .hint { font-weight: 400; color: var(--muted); font-size: .75rem; }
label.check { flex-direction: row; align-items: center; gap: 9px; font-weight: 500; }

input, select, textarea {
  padding: 8px 10px; font: inherit; font-size: .9rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type="checkbox"] { width: auto; }
input::placeholder { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; font: inherit; font-size: .88rem; font-weight: 600;
  border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
  align-self: flex-start; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: .8rem; }
.btn svg { width: 15px; height: 15px; }

button { font-family: inherit; }

/* ---------- avisos ------------------------------------------------------ */

.flash {
  padding: 11px 15px; border-radius: var(--radius); margin-bottom: 18px;
  border: 1px solid var(--accent); border-left-width: 3px; background: var(--accent-soft); color: var(--ink);
  font-size: .9rem;
}
.flash.err { border-color: var(--danger); background: var(--danger-soft); }

.callout {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--accent-soft); padding: 12px 15px; border-radius: var(--radius);
  font-size: .88rem; color: var(--ink-2);
}
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.callout b { color: var(--ink); }

.problems { margin: 0; padding: 12px 15px 12px 32px; border-radius: var(--radius);
  background: var(--warn-soft); border-left: 3px solid var(--warn); font-size: .87rem; color: var(--ink-2); }

.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 30px; height: 30px; opacity: .4; margin-bottom: 8px; }
.empty p { margin: 0 0 4px; }

/* ---------- listas de definição ---------------------------------------- */

dl.def { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0; font-size: .88rem; }
dl.def dt { color: var(--muted); }
dl.def dd { margin: 0; word-break: break-word; }

/* ---------- código / cópia ---------------------------------------------- */

.copy { display: inline-flex; align-items: center; gap: 6px; }
.copy button {
  background: transparent; border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 6px; font-size: .7rem; color: var(--muted); cursor: pointer;
}
.copy button:hover { color: var(--accent); border-color: var(--accent); }

.bigcode {
  font-family: Consolas, ui-monospace, monospace; font-size: 1.9rem; font-weight: 700;
  letter-spacing: .18em; color: var(--accent);
}

/* ---------- login -------------------------------------------------------- */

.authpage { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.authcard { width: 100%; max-width: 372px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 30px; box-shadow: var(--shadow); }
.authcard .brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.authcard .brand .mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent);
  color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.authcard .brand b { display: block; font-size: 1rem; }
.authcard .brand span { font-size: .74rem; color: var(--muted); }
.authcard .btn { width: 100%; }

/* ---------- responsivo --------------------------------------------------- */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
    transform: translateX(-100%); transition: transform .18s ease;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 18px 16px 56px; }
  .topbar { padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
