:root {
  --bg: #f5f7fa; --card: #fff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --side: #0f2742; --side-text: #cbd5e1; --side-active: #1d4ed8;
  --brand: #1d4ed8; --brand-soft: #eff6ff; --ok: #15803d; --warn: #b45309; --err: #b91c1c;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.side { width: 236px; background: var(--side); color: var(--side-text); flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { padding: 18px 18px 6px; color: #fff; font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.side .birou { padding: 0 18px 14px; font-size: 12px; color: #94a3b8; border-bottom: 1px solid rgba(255,255,255,.08); }
.side nav { padding: 8px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--side-text); margin: 1px 0; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.activ { background: var(--side-active); color: #fff; }
.side nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 4px; }
.side nav .badge { margin-left: auto; background: #ef4444; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; }
.side .user { padding: 12px 18px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.ico { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.main { flex: 1; padding: 24px 28px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.burger { display: none; }

/* cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; cursor: pointer; transition: box-shadow .15s; }
.tile:hover { box-shadow: 0 4px 16px rgba(15,23,42,.07); }
.tile .ib { width: 40px; height: 40px; border-radius: 10px; background: #f1f5f9; display: grid; place-items: center; margin-bottom: 12px; }

/* forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
input[type=checkbox] { width: auto; }
.fg { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.fg .full { grid-column: 1 / -1; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); margin: 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f8fafc; }
.btn.p { background: var(--brand); color: #fff; border-color: var(--brand); } .btn.p:hover { background: #1e40af; }
.btn.d { color: var(--err); } .btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.bar > * { width: auto; }

/* tables */
.tw { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.t tr.click:hover td { background: #f8fafc; cursor: pointer; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; background: #f1f5f9; color: #334155; white-space: nowrap; }
.pill.ok { background: #dcfce7; color: var(--ok); } .pill.warn { background: #fef3c7; color: var(--warn); } .pill.err { background: #fee2e2; color: var(--err); } .pill.info { background: var(--brand-soft); color: var(--brand); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.activ { color: var(--brand); border-color: var(--brand); font-weight: 600; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 720px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.lg { max-width: 1000px; }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toast { position: fixed; bottom: 20px; right: 20px; z-index: 99; display: flex; flex-direction: column; gap: 8px; }
#toast div { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 380px; }
#toast div.err { background: var(--err); }

/* calendar */
.cal { display: grid; grid-template-columns: 54px repeat(7, minmax(110px, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; min-width: 860px; }
.cal .h { background: #f8fafc; padding: 8px; font-weight: 600; font-size: 12px; text-align: center; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .h.azi { background: var(--brand-soft); color: var(--brand); }
.cal .ora { font-size: 11px; color: var(--muted); padding: 2px 6px; border-top: 1px solid #f1f5f9; height: 52px; }
.cal .slot { border-top: 1px solid #f1f5f9; border-left: 1px solid var(--line); height: 52px; position: relative; cursor: pointer; }
.cal .slot:hover { background: #f8fafc; }
.ev { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 2px 6px; font-size: 11px; color: #fff; overflow: hidden; z-index: 2; cursor: pointer; line-height: 1.3; }
.luna { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.luna .z { min-height: 104px; border-left: 1px solid #f1f5f9; border-top: 1px solid #f1f5f9; padding: 4px 6px; font-size: 12px; cursor: pointer; }
.luna .z.alt { background: #fafafa; color: #94a3b8; } .luna .z.azi .n { background: var(--brand); color: #fff; border-radius: 99px; padding: 0 6px; }
.luna .e { color: #fff; border-radius: 4px; padding: 0 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }

/* editor act */
.editor-tb { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: #f8fafc; }
.editor { min-height: 420px; border: 1px solid var(--line); border-radius: 0 0 10px 10px; padding: 40px 56px; background: #fff; font-family: "Times New Roman", serif; font-size: 15px; line-height: 1.6; outline: none; }
/* tipografia actului: text stânga-dreapta, cu alineat la începutul fiecărui paragraf/articol */
.editor p { margin: 0 0 8px; text-align: justify; text-indent: 1.25cm; }
.editor p[style*="center"] { text-indent: 0; }
.editor table p { text-indent: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips code { background: #f1f5f9; padding: 2px 7px; border-radius: 6px; font-size: 12px; cursor: pointer; }

/* bare grafice */
.hbar { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.hbar .lb { width: 180px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .tr { flex: 1; background: #f1f5f9; border-radius: 4px; height: 14px; }
.hbar .fl { background: var(--brand); height: 100%; border-radius: 4px; }
.hbar .vl { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }

/* drop zone & OCR */
.drop { border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 36px; text-align: center; color: var(--muted); cursor: pointer; background: #fff; }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.prev img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.progress { height: 6px; background: #e2e8f0; border-radius: 4px; overflow: hidden; } .progress div { height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #0f2742, #1d4ed8); }
.login { background: #fff; border-radius: 18px; padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 30px 60px rgba(0,0,0,.25); }

@media print {
  .side, .top .bar, .noprint, .editor-tb { display: none !important; }
  .main { padding: 0; } .card { border: 0; padding: 0; } .editor { border: 0; padding: 0; }
  body { background: #fff; }
}
@media (max-width: 900px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g2 { grid-template-columns: 1fr; }
  .side { position: fixed; left: -260px; z-index: 40; transition: left .2s; }
  .side.open { left: 0; }
  .burger { display: inline-flex; }
  .main { padding: 16px; }
  .editor { padding: 20px; }
}
