/* ============================================================
   cc-compare - визуален стил по образец на съществуващото ЕРП
   (тъмно ляво меню, индиго акцент, бели карти със статистики)
   ============================================================ */

:root {
  --sidebar-bg: #141829;
  --sidebar-bg-hover: #1d2238;
  --sidebar-text: #aab0c6;
  --sidebar-text-dim: #6b7290;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --bg: #f4f5fa;
  --card-bg: #ffffff;
  --border: #e6e8f0;
  --text: #1a1d2b;
  --text-dim: #6b7290;
  --danger: #dc2626;
  --danger-soft: #fde8e8;
  --success: #16a34a;
  --success-soft: #e7f9ee;
  --warn: #d97706;
  --warn-soft: #fef3e0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 41, 0.04), 0 4px 16px rgba(20, 24, 41, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

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

.layout { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px 8px;
}

.sidebar-logo .mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  flex-shrink: 0;
}

.sidebar-logo .name {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.sidebar-section-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--sidebar-text-dim);
  text-transform: uppercase;
  padding: 10px 10px 6px 10px;
}

.sidebar-nav { list-style: none; margin: 0; padding: 0; flex: 1; }

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  margin-bottom: 2px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.sidebar-nav .nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }

.sidebar-nav .nav-item:hover {
  background: var(--sidebar-bg-hover);
  color: #fff;
  text-decoration: none;
}

.sidebar-nav .nav-item.active {
  background: var(--accent);
  color: #fff;
}

.sidebar-nav .nav-item.active svg { opacity: 1; }

.sidebar-group-gap { height: 14px; }

.sidebar-footer {
  font-size: 11px;
  color: var(--sidebar-text-dim);
  padding: 14px 10px 4px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 10px;
}

/* ---------------- Main content ---------------- */

.main { flex: 1; min-width: 0; padding: 26px 32px 60px 32px; }

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.topbar .page-title { font-size: 23px; font-weight: 700; margin: 0; }

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-dim);
}

.topbar-meta .user-chip { display: flex; align-items: center; gap: 6px; }

/* ---------------- Cards ---------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px 18px;
  position: relative;
}

.stat-card .label {
  font-size: 11.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}

.stat-card .icon-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card .icon-badge svg { width: 17px; height: 17px; }

.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 8px; }

.stat-card .sub { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px;
  margin-bottom: 20px;
}

.card > .card-title {
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 14px;
}

/* ---------------- Table ---------------- */

table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

table.data-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data-table tr:hover td { background: #fafafe; }
table.data-table tr:last-child td { border-bottom: none; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-dim); }
.strike { text-decoration: line-through; color: var(--text-dim); }

/* ---------------- Badges / pills ---------------- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------------- Buttons / forms ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn svg { width: 15px; height: 15px; }

.btn-outline {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { background: #f7f7fb; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }

input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); display: block; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 160px; }

.form-hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}
.form-success {
  background: var(--success-soft);
  color: var(--success);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}

/* ---------------- Login ---------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 34px;
  width: 100%;
  max-width: 360px;
}

.login-card .sidebar-logo { padding: 0 0 22px 0; justify-content: center; }
.login-card .sidebar-logo .name { color: var(--text); font-size: 17px; }

.login-2fa-wrap { text-align: center; padding: 20px 0; }
.login-2fa-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  margin: 18px auto; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Misc ---------------- */

.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  background: #fff;
  border: 1px solid var(--border);
}
.tabs a:hover { text-decoration: none; background: #f7f7fb; }
.tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-dim); }

/* ---------------- Компактни калкулатори + панел "Сметка" ---------------- */
/* По изрично искане - по-малки и центрирани на страницата, не разтеглени
   на цялата широчина на .main (виж скрийншота, който Dimitar прати). */

.calc-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 720px;
  margin: 0 auto;
}
.calc-layout > .calc-card { flex: 0 1 350px; min-width: 270px; }
.calc-layout > .bill-panel { flex: 0 1 320px; min-width: 270px; }

.calc-card.card { padding: 16px 18px; }
.calc-card .card-title {
  text-align: center;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  margin-bottom: 12px;
}
.calc-card .field { margin-bottom: 10px; }
.calc-card .field-row { gap: 8px; margin-bottom: 0; }
.calc-card label { font-size: 11px; margin-bottom: 3px; }
.calc-card input, .calc-card select {
  padding: 6px 8px;
  font-size: 12.5px;
}

.calc-output-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.calc-output-row .output-box { flex: 1; min-width: 110px; margin-bottom: 0; }
.output-box label { margin-bottom: 3px; }
.output-box input:disabled {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  border-color: transparent;
  cursor: default;
  -webkit-text-fill-color: var(--accent);
  opacity: 1;
}

.calc-subline {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 12px 0;
}
.calc-subline input {
  width: 80px;
  flex: 0 0 80px;
  padding: 4px 6px;
  font-size: 11.5px;
}
.calc-subline .muted { font-size: 10.5px; }

.calc-total-box {
  background: var(--sidebar-bg);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.calc-total-box .label { font-size: 11px; color: var(--sidebar-text-dim); font-weight: 600; }
.calc-total-box .value { font-size: 17px; font-weight: 700; }

.calc-countdown { font-size: 10.5px; color: var(--text-dim); margin-top: 6px; text-align: center; }

.bill-panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  font-size: 12.5px;
}
.bill-panel .card-title { text-align: center; }
.bill-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.bill-panel-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff; color: var(--text-dim); cursor: pointer;
}
.icon-btn:hover { background: #f7f7fb; color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn-sm { width: 24px; height: 24px; }
.icon-btn-sm svg { width: 12px; height: 12px; }

.bill-spot-line { font-size: 12.5px; color: var(--text-dim); margin-bottom: 10px; }

.btn-block { width: 100%; justify-content: center; margin-bottom: 14px; }

.bill-items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 260px; overflow-y: auto; }
.bill-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg);
  font-size: 12.5px;
}
.bill-item-desc { color: var(--text); }
.bill-item-sub { color: var(--text-dim); font-size: 11.5px; }
.bill-item-amount { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }

.bill-summary {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.bill-total { font-size: 15px; font-weight: 700; color: var(--text); margin-top: 4px; }

.bill-actions { display: flex; gap: 8px; align-items: center; }
.bill-actions input[type=text] { flex: 1; }
.btn-percent { background: var(--danger-soft); color: var(--danger); flex: 0 0 auto; }
.btn-percent:hover { background: #fbd5d5; }
.btn-print { background: var(--warn); color: #fff; flex: 0 0 auto; }
.btn-print:hover { background: #b45f04; }

.sparkline { display: block; }

.trend-up { color: var(--danger); font-weight: 700; }
.trend-down { color: var(--success); font-weight: 700; }
.trend-flat { color: var(--text-dim); font-weight: 700; }

.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px 0; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

@media (max-width: 880px) {
  .sidebar { display: none; }
  .main { padding: 18px; }
}
