/* Portal Valor Code Labs — culorile brandului: ink, navy, royal, blue, cyan, ice. */
:root {
  --ink: #020817;
  --navy: #071a3d;
  --royal: #0a4ca6;
  --blue: #0075d6;
  --cyan: #00b1eb;
  --ice: #5bdcff;

  --bg: #f3f6fa;
  --surface: #ffffff;
  --line: #e1e8f1;
  --text: #0b1b33;
  --muted: #5d6f87;
  --pos: #0a7d4f;
  --neg: #c2362b;
  --warn: #a8650a;

  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

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

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 10;
  background: var(--cyan);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
}

/* ───────── Structură ───────── */
.app {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 14px;
  background: linear-gradient(180deg, var(--ink), var(--navy));
  color: #e9f8ff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  color: inherit;
}
.brand:hover {
  text-decoration: none;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.brand-name {
  font-size: 19px;
  letter-spacing: 0.14em;
}
.brand-sub {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--cyan);
  font: 9px var(--mono);
  letter-spacing: 0.32em;
  color: var(--cyan);
}

.sidebar nav {
  flex: 1;
}
.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.nav {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #a9bdd4;
  font-weight: 500;
}
.nav:hover {
  background: rgb(255 255 255 / 0.06);
  color: #fff;
  text-decoration: none;
}
.nav .badge {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--cyan);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.nav.active {
  background: rgb(0 177 235 / 0.16);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--cyan);
}

.who {
  padding: 14px 12px 0;
  border-top: 1px solid rgb(255 255 255 / 0.1);
  font-size: 13px;
}
.who-name {
  font-weight: 600;
}
.who-role {
  color: #8da5be;
  margin-bottom: 6px;
}
.who .link {
  color: var(--ice);
}

.main {
  padding: 28px clamp(16px, 3vw, 40px) 60px;
  min-width: 0;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 22px;
}
h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 650;
}
h2 small {
  margin-left: 8px;
  font-weight: 400;
  color: var(--muted);
}
h3 {
  margin: 18px 0 8px;
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

/* ───────── Carduri și cifre ───────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.tile-label {
  color: var(--muted);
  font-size: 13px;
}
.tile-value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.tile-hint {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}
.pos {
  color: var(--pos);
}
.neg {
  color: var(--neg);
}
.warn {
  color: var(--warn);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 18px;
  align-items: start;
}
.grid-2 > .card {
  margin-bottom: 0;
}
.grid-2 {
  margin-bottom: 18px;
}

/* ───────── Tabele ───────── */
.table-wrap {
  overflow-x: auto;
  margin: 0 -6px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th,
td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
thead th {
  font: 600 11px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tfoot th,
tfoot td {
  border-top: 2px solid var(--line);
  border-bottom: 0;
  font-weight: 650;
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
td.date {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
tr.dim td {
  color: #9aa9bc;
}
td.actions {
  white-space: nowrap;
  text-align: right;
}
td.actions > * + * {
  margin-left: 12px;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e8f1fb;
  color: var(--royal);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tag.gray {
  background: #eef1f5;
  color: var(--muted);
}
.tag.amber {
  background: #fdf1dd;
  color: var(--warn);
}
.tag.green {
  background: #e2f5ec;
  color: var(--pos);
}

.empty {
  margin: 0;
  padding: 18px 0;
  color: var(--muted);
}

.steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

/* ───────── Filtre ───────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 5px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.chip:hover {
  border-color: var(--blue);
  color: var(--text);
  text-decoration: none;
}
.chip.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* ───────── Formulare ───────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px 16px;
}
.form-grid .wide {
  grid-column: 1 / -1;
}
.stack {
  display: grid;
  gap: 14px;
}
.field {
  display: grid;
  gap: 5px;
  align-content: start;
}
.field-label {
  font-size: 13px;
  font-weight: 600;
}
.field-hint {
  font-size: 12px;
  color: var(--muted);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #c9d4e2;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
textarea {
  min-height: 70px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgb(0 117 214 / 0.18);
}

/* Câmp de parolă cu buton de afișare (adăugat de app.js) */
.pw {
  position: relative;
  display: block;
}
.pw input {
  padding-right: 42px;
}
.pw-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0 8px 8px 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.pw-toggle:hover,
.pw-toggle[aria-pressed="true"] {
  color: var(--royal);
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
}
.check input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font: 600 14px var(--font);
  cursor: pointer;
}
.btn:hover {
  background: var(--royal);
  text-decoration: none;
}
.btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid #c9d4e2;
}
.btn.secondary:hover {
  border-color: var(--blue);
  background: #fff;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--royal);
  font: inherit;
  cursor: pointer;
}
button.link:hover {
  text-decoration: underline;
}
.danger {
  color: var(--neg) !important;
}
form.inline {
  display: inline;
}

details.adder {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
details.adder > summary {
  padding: 14px 20px;
  cursor: pointer;
  font-weight: 650;
  list-style: none;
}
details.adder > summary::-webkit-details-marker {
  display: none;
}
details.adder > summary::before {
  content: "+";
  display: inline-block;
  width: 20px;
  color: var(--blue);
  font-weight: 700;
}
details.adder[open] > summary::before {
  content: "−";
}
details.adder > .adder-body {
  padding: 4px 20px 20px;
}

.alloc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px 14px;
}
.alloc-grid label {
  display: grid;
  grid-template-columns: 1fr 76px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
[hidden] {
  display: none !important;
}

/* ───────── Mesaje ───────── */
.notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid;
  font-size: 14px;
}
.notice-ok {
  background: #e7f6ee;
  border-color: #b5e2c9;
  color: #0b5a3a;
}
.notice-error {
  background: #fdecea;
  border-color: #f3beb8;
  color: #8f2219;
}
.notice-info {
  background: #eaf3fd;
  border-color: #c2dcf6;
  color: #114a85;
}

/* ───────── Bare de proporție ───────── */
.bar {
  height: 6px;
  border-radius: 3px;
  background: #e6edf5;
  overflow: hidden;
  min-width: 80px;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--blue);
}
.bar.over > span {
  background: var(--neg);
}

/* ───────── Autentificare ───────── */
body.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, #0a2a5c, var(--ink) 70%);
}
.auth-card {
  width: min(100%, 400px);
  padding: 30px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.45);
}
.auth-card .brand {
  padding: 14px 16px;
  margin-bottom: 22px;
  border-radius: 12px;
  background: var(--ink);
  color: #e9f8ff;
}
.auth-card h1 {
  margin-bottom: 16px;
  font-size: 21px;
}

.qr {
  display: block;
  width: 190px;
  height: 190px;
  image-rendering: pixelated;
  border: 8px solid #fff;
  outline: 1px solid var(--line);
}
code {
  font: 13px var(--mono);
  background: #eef2f7;
  padding: 1px 6px;
  border-radius: 5px;
  word-break: break-all;
}

/* ───────── Ecrane înguste ───────── */
@media (max-width: 860px) {
  /* tabelele late derulează orizontal în loc să își înghesuie coloanele */
  .table-wrap > table {
    min-width: 620px;
  }
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    gap: 12px;
    padding: 14px;
  }
  .sidebar ul {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 4px;
  }
  .nav {
    white-space: nowrap;
  }
  .nav.active {
    box-shadow: inset 0 -3px 0 var(--cyan);
  }
  .who {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 10px;
  }
  .who-role {
    margin: 0;
    flex: 1;
  }
}

@media print {
  .sidebar,
  .filters,
  details.adder,
  td.actions,
  .no-print {
    display: none !important;
  }
  .app {
    display: block;
  }
  body {
    background: #fff;
  }
  .card,
  .tile {
    border-color: #999;
    break-inside: avoid;
  }
}
