:root {
  --bg: #f7f3ed;
  --panel: #fffaf4;
  --text: #0d1b2f;
  --muted: #5d6980;
  --line: #ead8bd;
  --accent: #d47913;
  --accent-dark: #9a4f04;
  --nav: #25344d;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --soft: #fff7ed;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 22px 34px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { min-width: 280px; }
.eyebrow { color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: .16em; font-size: 12px; }
h1 { margin: 4px 0 0; font-size: 32px; letter-spacing: .06em; font-weight: 600; }
h2 { margin: 0 0 8px; font-size: 20px; }
h3 { margin: 16px 0 8px; font-size: 16px; }
p { color: var(--muted); margin: 0; line-height: 1.45; }
main { padding: 24px 34px 40px; max-width: 1540px; margin: auto; }

.server-version-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f5f8fc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.server-version-badge strong { color: var(--text); }
.server-version-badge.error { border-color: #f1b7b2; background: #fff0ef; color: var(--bad); }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
a, button, .file-button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
}
button:hover, a:hover, .file-button:hover { filter: brightness(.96); }
button.secondary, a.secondary { background: var(--nav); }
button.danger { background: var(--bad); }
button.small { padding: 6px 8px; min-height: 30px; font-size: 12px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.file-button input { display: none; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 8px 30px rgba(13, 27, 47, .06);
}
.login-panel { max-width: 520px; margin: 44px auto; }
.login-form, .form-grid { display: grid; gap: 12px; margin-top: 18px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 6px; font-weight: 800; color: var(--text); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input[type="checkbox"] { width: auto; }
.message { margin-top: 10px; color: var(--muted); font-weight: 800; min-height: 20px; }
.message.inline { margin-top: 0; align-self: end; }
.message.error { color: var(--bad); }
.message.ok { color: var(--ok); }
.message.warn { color: var(--warn); }
.hidden { display: none !important; }
.status-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  padding: 14px;
  border-radius: 10px;
}
.stat-card strong { display: block; font-size: 26px; line-height: 1; }
.stat-card span { color: var(--muted); font-size: 13px; }
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.tab {
  background: transparent;
  color: var(--nav);
  border: 1px solid transparent;
  min-height: 34px;
  padding: 8px 10px;
}
.tab.active {
  color: #fff;
  background: var(--nav);
}
.toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.compact-toolbar { margin-top: 12px; }
.grow { flex: 1 1 360px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dashboard-grid { grid-template-columns: 2fr 1fr; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.panel-header { display: flex; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 14px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.cards-list { display: grid; gap: 10px; }
.item-card { background: white; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px; }
.item-card.online { border-left-color: var(--ok); }
.item-card.stale { border-left-color: var(--warn); }
.item-card.offline { border-left-color: var(--bad); }
.item-card strong { display: block; margin-bottom: 5px; }
.item-card small { color: var(--muted); display: block; line-height: 1.5; }
.item-card .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.compact .item-card { padding: 10px; }
.action-list { display: grid; gap: 9px; margin-top: 10px; }
.action-list.horizontal { display: flex; flex-wrap: wrap; align-items: center; }
.info-box {
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 700;
}
.table-wrap { overflow: auto; max-width: 100%; background: white; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #f0dfc4; vertical-align: top; }
th { background: #fff3e2; color: var(--text); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; z-index: 1; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 800;
  font-size: 12px;
  background: #e5e7eb;
  color: #374151;
}
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.bad { background: #fee2e2; color: var(--bad); }
.scroll-box {
  max-height: 520px;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.log-line { border-bottom: 1px solid #f0dfc4; padding: 8px 4px; font-size: 13px; }
.log-line:last-child { border-bottom: 0; }
.log-line strong { display: block; }
.log-line small { color: var(--muted); display: block; margin-top: 3px; }
.pre-box {
  background: #101827;
  color: #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
  max-height: 520px;
  font-size: 12px;
  white-space: pre-wrap;
}
.mt { margin-top: 12px; }
.live-mark { text-align: center; font-weight: 900; }
.live-mark.yes { color: var(--ok); }
.live-mark.no { color: #cbd5e1; }
@media (max-width: 1100px) {
  .topbar, .panel-header { flex-direction: column; align-items: stretch; }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid, .dashboard-grid { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  main { padding: 18px; }
}
@media (max-width: 650px) {
  .topbar { padding: 18px; }
  h1 { font-size: 26px; }
  .status-strip { grid-template-columns: 1fr; }
  .top-actions, .toolbar { align-items: stretch; }
  a, button, .file-button { width: 100%; }
}


/* v0.65 chat + competitor proposals */
.chat-layout { display: grid; grid-template-columns: 280px 1fr; gap: 14px; align-items: stretch; }
.chat-contacts, .chat-main { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.chat-messages { height: 420px; overflow: auto; background: #fbfbfb; border: 1px solid #f0dfc4; border-radius: 10px; padding: 12px; }
.chat-line { max-width: 78%; margin: 0 0 10px; padding: 10px; border-radius: 10px; background: #fff7ed; border: 1px solid #f0dfc4; }
.chat-line.mine { margin-left: auto; background: #eef6ff; }
.chat-line p { margin: 4px 0; color: var(--text); white-space: pre-wrap; }
.chat-line small { color: var(--muted); }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1 1 auto; }
#competitorProposalsTable small { color: var(--muted); }
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; } .chat-line { max-width: 96%; } }


/* v0.66: arbitraj online Admin - tabel sortabil, aliniere și detalii sumă */
.live-admin-table th.judge-col,
.live-admin-table td.judge-col,
.live-admin-table th.total-col,
.live-admin-table td.total-col,
.live-admin-table .live-mark {
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}
.live-admin-table th.sortable { cursor: pointer; user-select: none; }
.live-admin-table th.sortable:hover { background: #ffe5bd; }
.live-admin-table .num-col { width: 72px; white-space: nowrap; }
.live-admin-table .competitor-col { min-width: 240px; }
.live-admin-table .country-col { min-width: 130px; white-space: nowrap; color: #334155; }
.link-button { border: 0; background: transparent; color: inherit; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.live-total-button { font-weight: 900; color: var(--accent); }
.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .42); display: flex; align-items: center; justify-content: center; padding: 22px; }
.modal-card { width: min(760px, 96vw); max-height: 86vh; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 22px 70px rgba(15,23,42,.28); overflow: hidden; }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 14px 16px; background: #fff7ed; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-scroll { max-height: calc(86vh - 70px); overflow: auto; padding: 16px; }
.modal-scroll table { min-width: 420px; }

/* v2.0.4 - selector limbă Admin Console */
.admin-language-switcher { position: relative; }
.admin-language-button {
  background: var(--nav);
  min-width: 86px;
  border-radius: 10px;
}
.admin-language-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 200;
  min-width: 205px;
  display: grid;
  gap: 4px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(13,27,47,.18);
}
.admin-language-menu button {
  justify-content: flex-start;
  width: 100%;
  background: #fff;
  color: var(--text);
  min-height: 34px;
  padding: 7px 9px;
}
.admin-language-menu button:hover,
.admin-language-menu button.active { background: var(--soft); color: var(--accent-dark); }
.admin-flag {
  width: 22px;
  height: 14px;
  display: inline-block;
  border: 1px solid rgba(0,0,0,.18);
  border-radius: 2px;
  flex: 0 0 auto;
}
.admin-flag-ro { background: linear-gradient(90deg,#002b7f 0 33.333%,#fcd116 33.333% 66.666%,#ce1126 66.666%); }
.admin-flag-en { background: linear-gradient(180deg,#b22234 0 8%,#fff 8% 16%,#b22234 16% 24%,#fff 24% 32%,#b22234 32% 40%,#fff 40% 48%,#b22234 48% 56%,#fff 56% 64%,#b22234 64% 72%,#fff 72% 80%,#b22234 80% 88%,#fff 88% 96%,#b22234 96%); }
.admin-flag-ru { background: linear-gradient(180deg,#fff 0 33.333%,#0039a6 33.333% 66.666%,#d52b1e 66.666%); }
.admin-flag-es { background: linear-gradient(180deg,#aa151b 0 25%,#f1bf00 25% 75%,#aa151b 75%); }
.admin-flag-it { background: linear-gradient(90deg,#009246 0 33.333%,#fff 33.333% 66.666%,#ce2b37 66.666%); }
.admin-flag-tr { position:relative; background:#e30a17; }
.admin-flag-tr::before { content:"☾"; position:absolute; color:#fff; font-size:12px; left:3px; top:-2px; }
.admin-flag-tr::after { content:"★"; position:absolute; color:#fff; font-size:6px; left:11px; top:1px; }
@media (max-width: 760px) {
  .topbar { align-items: flex-start; padding: 16px; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .admin-language-menu { left: 0; right: auto; }
}


/* v2.0.11 - Admin Console adaptivă și set de limbi RO/EN/RU */
html, body { min-width: 0; max-width: 100%; overflow-x: hidden; }
.topbar, main, .panel, .grid, .dashboard-grid, .tab-panel { min-width: 0; }
.topbar { padding: clamp(14px, 2vw, 28px); }
main { width: 100%; padding: clamp(12px, 2vw, 34px); }
.tabs { position: sticky; top: var(--admin-topbar-height, 112px); z-index: 8; }
.table-wrap, .scroll-box, .pre-box { max-width: 100%; overscroll-behavior: contain; }
input, select, textarea, button, a, .file-button { min-height: 42px; }
@media (max-width: 1100px) {
  :root { --admin-topbar-height: 164px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .tab { flex: 0 0 auto; }
  .form-grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  :root { --admin-topbar-height: 214px; }
  .topbar { gap: 12px; }
  .brand { min-width: 0; width: 100%; }
  .brand h1 { overflow-wrap: anywhere; }
  .top-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .top-actions > * { width: 100%; min-width: 0; }
  .admin-language-switcher { grid-column: 1 / -1; width: max-content; }
  .panel { padding: 13px; }
  .toolbar, .row-actions, .action-list.horizontal, .chat-form { flex-direction: column; align-items: stretch; }
  .toolbar > *, .row-actions > *, .action-list.horizontal > *, .chat-form > * { width: 100%; }
  .chat-messages { height: min(42vh, 360px); }
  .modal { padding: 8px; }
  .modal-card { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
}
@media (min-width: 1600px) and (min-height: 850px) {
  main { max-width: 1900px; font-size: 17px; }
  h1 { font-size: 40px; }
  h2 { font-size: 25px; }
  td { font-size: 15px; }
  th { font-size: 13px; }
  .panel { padding: 22px; }
}

/* v2.0.14 - administrare arborescentă a utilizatorilor */
.user-management-grid { align-items: start; }
.user-tree-wrap { max-height: min(68vh, 760px); }
.user-tree-wrap table { min-width: 1180px; }
.user-tree-cell { min-width: 250px; }
.user-tree-node {
  display: grid;
  gap: 4px;
  padding-left: calc(var(--tree-depth, 0) * 22px);
  position: relative;
}
.user-tree-node::before {
  content: "";
  position: absolute;
  left: calc(var(--tree-depth, 0) * 22px - 12px);
  top: 14px;
  width: 10px;
  border-top: 1px solid var(--line);
}
.user-tree-node[data-depth="0"]::before { display: none; }
.user-tree-node .tree-meta { color: var(--muted); font-size: 11px; font-weight: 700; }
.user-tree-node .self-badge { margin-left: 6px; }
.user-field { min-width: 150px; }
.user-field.compact { min-width: 100px; max-width: 130px; }
.user-role-select { min-width: 150px; }
.user-actions { min-width: 260px; }
.user-row-self { background: #fffaf0; }
.user-row-disabled { opacity: .72; }
.permission-note { font-size: 12px; color: var(--muted); }
.console-limited .status-strip,
.console-limited .toolbar { display: none !important; }
.console-limited .tabs { justify-content: flex-start; }

@media (max-width: 760px) {
  .user-tree-wrap { max-height: 64vh; }
  .user-tree-wrap table { min-width: 1080px; }
}
