/* SisLicit v2 — design portado do Flask */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222535;
  --border: #2e3148;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --text: #e2e4f0;
  --text-muted: #7b80a0;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ── Layout ──────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand { font-weight: 600; font-size: 1rem; color: var(--text); }
.navbar-brand span { color: var(--accent); }

.navbar-links { display: flex; gap: 4px; flex: 1; }
.navbar-links a {
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.navbar-links a:hover, .navbar-links a.active { color: var(--text); background: var(--surface2); }

.navbar-user { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; display: flex; align-items: center; gap: 10px; }

.container { max-width: 1280px; margin: 0 auto; padding: 24px 24px; }
.page-header { margin-bottom: 24px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.25rem; font-weight: 600; flex: 1; }

/* ── Cards & surfaces ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-body { padding: 16px 20px; }
.card-header { padding: 12px 20px; border-bottom: 1px solid var(--border); font-weight: 500; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 4px 8px; }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control[type="color"] { padding: 4px 8px; height: 36px; cursor: pointer; }
select.form-control { appearance: none; cursor: pointer; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
thead th.sorted { color: var(--accent); }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:hover { background: var(--surface2); }
tbody tr.saving { opacity: 0.6; }
tbody tr.new-item-row { background: color-mix(in srgb, var(--accent) 8%, transparent); }
td { padding: 8px 12px; vertical-align: middle; }
td.col-n { color: var(--text-muted); font-size: 0.75rem; font-family: var(--mono); width: 36px; }
td.col-vunit, td.col-vtotal { font-family: var(--mono); font-size: 0.82rem; text-align: right; }
td.col-actions { text-align: right; white-space: nowrap; }

/* ── Inline editing ──────────────────────────────────────────────────────── */
.cell-display {
  cursor: text;
  border-radius: 4px;
  padding: 2px 4px;
  transition: background 0.1s;
  min-height: 1.5em;
  display: block;
}
.cell-display:hover { background: var(--surface2); }
.cell-input {
  background: var(--surface2);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font);
  font-size: inherit;
  width: 100%;
}
.cell-input:focus { outline: none; }
.cell-input.num { font-family: var(--mono); text-align: right; }

/* ── Category badges ─────────────────────────────────────────────────────── */
.cat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
  border: 1px solid;
  cursor: pointer;
  white-space: nowrap;
}
.cat-none { color: var(--text-muted); font-size: 0.78rem; cursor: pointer; }
.cat-none:hover { color: var(--text); }

/* ── Category filter chips ───────────────────────────────────────────────── */
.cat-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.cat-chip {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid;
  cursor: pointer;
  opacity: 0.38;
  transition: opacity 0.15s;
}
.cat-chip.active { opacity: 1; }

/* ── Category dropdown ───────────────────────────────────────────────────── */
.cat-dropdown-wrap { position: relative; display: inline-block; }
.cat-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 160px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.cat-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.82rem;
}
.cat-dropdown button:hover { background: var(--surface2); }

/* ── Sort buttons ────────────────────────────────────────────────────────── */
.sort-btn {
  display: inline-flex; flex-direction: column; gap: 1px;
  margin-left: 4px; vertical-align: middle; cursor: pointer;
  opacity: 0.35; transition: opacity 0.15s; line-height: 1;
}
.sort-btn:hover { opacity: 0.7; }
.sort-btn.asc .arr-up, .sort-btn.desc .arr-down { opacity: 1; color: var(--accent); }
.sort-btn .arr-up, .sort-btn .arr-down { font-size: 0.55rem; display: block; line-height: 1; }

/* ── Bulk bar ────────────────────────────────────────────────────────────── */
.bulk-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
  border: 1px solid var(--accent);
  border-radius: 8px;
  margin-bottom: 12px;
}
.bulk-bar.visible { display: flex; }
.bulk-count { font-size: 0.82rem; color: var(--text-muted); margin-right: auto; }

/* ── New item panel ──────────────────────────────────────────────────────── */
.new-item-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.new-item-panel.open { display: block; }
.new-item-grid { display: grid; grid-template-columns: 1fr 1fr 80px 90px 120px 120px; gap: 8px; align-items: end; }
@media (max-width: 768px) { .new-item-grid { grid-template-columns: 1fr 1fr; } }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: min(520px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: color-mix(in srgb, var(--success) 15%, transparent); border: 1px solid var(--success); color: var(--success); }
.alert-danger  { background: color-mix(in srgb, var(--danger)  15%, transparent); border: 1px solid var(--danger);  color: var(--danger); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.85rem;
  z-index: 1000;
  transform: translateY(80px); opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.ok   { border-color: var(--success); color: var(--success); }
#toast.err  { border-color: var(--danger);  color: var(--danger); }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: min(380px, 95vw); }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.mono { font-family: var(--mono); }
.gap-8 { gap: 8px; }
.flex { display: flex; align-items: center; }
.ml-auto { margin-left: auto; }
.hidden { display: none !important; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
