:root {
  --bg: #f4f6f9;
  --bg-2: #eceff3;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --panel-solid: #ffffff;
  --border: #e3e7ee;
  --border-strong: #cbd2dd;
  --text: #1f2733;
  --muted: #6b7688;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: #eaf0fe;
  --ok: #16a34a;
  --ok-soft: #e8f6ec;
  --warn: #b45309;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --indigo: #6d5ae0;
  --indigo-soft: #eeecfb;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 6px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.12);
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
#root { height: 100vh; }

a { color: inherit; text-decoration: none; }
.link { color: var(--primary); font-weight: 500; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.r { text-align: right; }
.warn { color: var(--warn); }

/* ---------- Buttons ---------- */
.btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: 0.15s ease;
}
.btn:hover { background: var(--panel-2); border-color: #b5bdca; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.block { width: 100%; }
.icon-btn {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; padding: 4px 6px; border-radius: 6px; transition: 0.15s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

input, select {
  background: #fff;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13px;
  width: 100%;
  transition: 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14); }
input:disabled, select:disabled { background: var(--panel-2); color: var(--muted); cursor: not-allowed; }
input[type='checkbox'] { width: auto; accent-color: var(--primary); }

/* ---------- Login ---------- */
.login-wrap { height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg-2); }
.login-card {
  width: 372px; background: #fff; border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; box-shadow: var(--shadow-lg);
}
.login-card label { display: block; margin: 15px 0 6px; font-size: 12px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand h1 { font-size: 21px; margin: 0; color: var(--text); font-weight: 700; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 18px;
}
.login-card .btn { margin-top: 22px; }
.hint { margin-top: 18px; font-size: 11px; color: var(--muted); text-align: center; }
.form-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: 8px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 262px 1fr; height: 100vh; }
.sidebar {
  background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand.small { margin-bottom: 24px; padding-left: 4px; }
.brand.small span { font-weight: 700; font-size: 16px; color: var(--text); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { padding: 10px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; transition: 0.14s; position: relative; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-2); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: var(--primary); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; }
.user-chip { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--muted); }

.content { overflow-y: auto; padding: 26px 30px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 3px; font-size: 22px; font-weight: 700; color: var(--text); }
.page-head p { margin: 0; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-actions .year-input { width: 90px; }
.page-actions select { width: auto; }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.error { color: var(--danger); border-color: #f3c7c7; background: var(--danger-soft); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.inline-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-controls select, .inline-controls input { width: auto; }
.inline-controls .year-input { width: 90px; }

/* Sub-section heading inside a card (e.g. "Calculat automat") */
.section-head { margin: 22px 0 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.section-head h3 { margin: 0; font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: 0.01em; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } .layout { grid-template-columns: 208px 1fr; } }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 15px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--muted); }
.field.row { flex-direction: row; align-items: center; gap: 8px; }
.field-title { font-weight: 600; color: var(--text) !important; margin-bottom: 4px; }
.inline-note { margin-top: 14px; font-size: 12px; color: var(--muted); }

/* ---------- Computed results ---------- */
.computed-grid { display: flex; flex-direction: column; gap: 1px; }
.computed-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 8px; }
.computed-item:nth-child(odd) { background: var(--panel-2); }
.ci-label { color: var(--muted); }
.ci-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.computed-item.highlight { background: var(--primary-soft); border: 1px solid #c7d7fb; margin: 7px 0; }
.computed-item.highlight .ci-label { color: var(--primary-2); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: 12px; }
.computed-item.highlight .ci-value { color: var(--primary-2); font-size: 17px; }

/* ---------- Stat strip ---------- */
.stat-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 15px; min-width: 122px; }
.stat-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.stat-value { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
table.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.grid th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.grid tbody tr:hover { background: var(--panel-2); }
table.grid tfoot td { border-top: 2px solid var(--border-strong); border-bottom: none; font-weight: 700; }
table.grid.compact th, table.grid.compact td { padding: 7px 9px; font-size: 12px; }
table.grid .strong { font-weight: 700; color: var(--primary-2); }
table.grid tr.strong-row td { background: var(--primary-soft); font-weight: 700; }
table.grid td.narrow input { width: 80px; }
.muted-row td { opacity: 0.55; }
.table-scroll { overflow-x: auto; max-width: 100%; }

/* ---------- Tags & chips ---------- */
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border-strong); }
.tag.ok { color: var(--ok); background: var(--ok-soft); border-color: #bfe6c9; }
.tag.super { color: var(--indigo); background: var(--indigo-soft); border-color: #d7d1f5; }
.tag.mgr { color: var(--ok); background: var(--ok-soft); border-color: #bfe6c9; }
.narrow-card { max-width: 640px; }
.perm-chips { display: flex; flex-wrap: wrap; gap: 5px; }
/* Lămurirea de sub eticheta reprezentanței, în coloana Acces */
.access-note { margin-top: 6px; line-height: 1.4; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.perm-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; grid-column: 1 / -1; }
.perm-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 7px; border-radius: 7px; background: var(--panel-2); border: 1px solid var(--border); }

.empty { text-align: center; color: var(--muted); padding: 32px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, 0.4); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border: 1px solid var(--border); border-radius: 12px; width: min(560px, 96vw); max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(16px); background: #fff; border: 1px solid var(--border-strong); border-left: 4px solid var(--muted); color: var(--text); padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: 0.24s; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }

/* scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: #d3d9e2; border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #bcc4d0; }
