@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* ===== NAVBAR ===== */
.navbar {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 1px solid #1e293b;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-size: 16px;
  font-weight: 700;
  color: #f1f5f9;
  text-decoration: none;
  letter-spacing: -0.5px;
}
.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-links a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-links a:hover, .nav-links a:active {
  color: #e2e8f0;
  background: #1e293b;
  border-color: #334155;
}

/* ===== CONTAINER ===== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== ALERTS ===== */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  border: 1px solid;
}
.alert-success { background: #052e16; border-color: #166534; color: #4ade80; }
.alert-error { background: #450a0a; border-color: #991b1b; color: #fca5a5; }

/* ===== KPI CARDS ===== */
.kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.kpi-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 14px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.kpi-card:hover { border-color: #475569; }
.kpi-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.accent-blue { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.accent-green { background: linear-gradient(90deg, #10b981, #34d399); }
.accent-amber { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.accent-rose { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.accent-violet { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.kpi-label {
  font-size: 10px;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.2;
  word-break: break-word;
}
.kpi-sub {
  font-size: 10px;
  color: #64748b;
  margin-top: 4px;
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}
.search-form input[type="text"] {
  flex: 1;
  min-width: 0;
}
.search-form select {
  flex: 1;
  min-width: 100px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}
.btn-primary:hover, .btn-primary:active { background: #2563eb; }
.btn-secondary {
  background: #1e293b;
  color: #94a3b8;
  border-color: #334155;
}
.btn-secondary:hover, .btn-secondary:active {
  background: #334155;
  color: #e2e8f0;
}
.btn-sm {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-edit {
  background: transparent;
  color: #60a5fa;
  border-color: #334155;
}
.btn-edit:hover, .btn-edit:active { background: #1e3a5f; }
.btn-delete {
  background: transparent;
  color: #f87171;
  border-color: #334155;
}
.btn-delete:hover, .btn-delete:active { background: #450a0a; }

/* ===== FORM INPUTS ===== */
input, select, textarea {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  color: #e2e8f0;
  font-size: 16px; /* prevent iOS zoom */
  font-family: inherit;
  transition: border-color 0.2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #3b82f6;
}
select { cursor: pointer; }

/* ===== TABLE ===== */
.table-wrap {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}
th {
  text-align: left;
  padding: 10px 10px;
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #334155;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: #1e293b;
}
th a {
  color: inherit;
  text-decoration: none;
}
th a:hover { color: #94a3b8; }
td {
  padding: 10px 10px;
  font-size: 12px;
  border-bottom: 1px solid #1e293b;
  color: #cbd5e1;
}
tr:hover td { background: #162032; }
.mono { font-family: 'JetBrains Mono', 'SF Mono', monospace; font-size: 11px; }
.text-right { text-align: right; }
.text-warn { color: #fbbf24; font-weight: 600; }
.ref-cell { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: #475569; padding: 32px 10px !important; }
.actions { white-space: nowrap; display: flex; gap: 4px; }

/* ===== MOBILE CARD VIEW for table ===== */
.mobile-cards { display: flex; flex-direction: column; gap: 8px; }
.mobile-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 14px;
}
.mobile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.mobile-card-nr {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
}
.mobile-card-ref {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-card-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
}
.mobile-card-label { color: #64748b; }
.mobile-card-val { color: #cbd5e1; font-weight: 500; }
.mobile-card-val.warn { color: #fbbf24; }
.mobile-card-tags {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.mobile-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #263044;
}
.mobile-card-actions .btn-sm { flex: 1; text-align: center; }

/* Hide table on mobile, show cards; hide cards on desktop, show table */
.table-wrap { display: none; }
.mobile-cards { display: flex; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-deschisa { background: #1e3a5f; color: #60a5fa; }
.badge-in-asteptare { background: #422006; color: #fbbf24; }
.badge-finalizata { background: #052e16; color: #4ade80; }

/* ===== TAGS ===== */
.tags { display: flex; gap: 3px; flex-wrap: wrap; }
.tag {
  padding: 2px 6px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 4px;
  font-size: 9px;
  color: #94a3b8;
  white-space: nowrap;
}

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
}
.login-brand {
  font-size: 22px;
  font-weight: 700;
  color: #f1f5f9;
  text-align: center;
  letter-spacing: -0.5px;
}
.login-subtitle {
  font-size: 13px;
  color: #64748b;
  text-align: center;
  margin-bottom: 24px;
}
.login-field {
  margin-bottom: 16px;
}
.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.login-btn {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 14px;
}
.nav-logout {
  color: #f87171 !important;
}
.nav-logout:hover, .nav-logout:active {
  background: #450a0a !important;
  border-color: #7f1d1d !important;
}

/* ===== UPLOAD ===== */
.upload-label { cursor: pointer; }
.upload-form { width: 100%; }

/* ===== FORM CARD ===== */
.form-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 20px;
  max-width: 900px;
}
.form-card h2 {
  font-size: 18px;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 20px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.full-width { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  gap: 10px;
}
.form-actions .btn { flex: 1; }

/* ===== CHARTS ===== */
.charts-grid,
.charts-grid-half,
.charts-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.chart-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 16px;
  overflow: hidden;
}
.chart-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 14px;
}
.chart-container {
  position: relative;
  height: 220px;
}

/* ===== STATUS LIST ===== */
.status-list { display: flex; flex-direction: column; gap: 8px; }
.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #0f172a;
  border-radius: 8px;
  border: 1px solid #1e293b;
}
.status-item .left { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-green { background: #10b981; box-shadow: 0 0 8px rgba(16,185,129,0.4); }
.dot-blue { background: #3b82f6; box-shadow: 0 0 8px rgba(59,130,246,0.4); }
.dot-amber { background: #f59e0b; box-shadow: 0 0 8px rgba(245,158,11,0.4); }
.status-item .name { font-size: 13px; color: #cbd5e1; }
.status-item .count { font-size: 18px; font-weight: 700; color: #f1f5f9; }

/* ===== PROGRESS BAR ===== */
.progress-section { margin-top: 16px; }
.progress-bar-bg {
  width: 100%; height: 8px; background: #0f172a;
  border-radius: 4px; overflow: hidden; display: flex;
}
.progress-segment { height: 100%; transition: width 0.6s ease; }
.progress-labels {
  display: flex; justify-content: space-between;
  margin-top: 6px; font-size: 10px; color: #64748b;
}

/* ===== DEBT TABLE ===== */
.debt-table { width: 100%; border-collapse: collapse; }
.debt-table th {
  text-align: left; font-size: 10px; font-weight: 500;
  color: #64748b; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 6px 8px; border-bottom: 1px solid #334155;
}
.debt-table td {
  font-size: 12px; color: #cbd5e1;
  padding: 8px 8px; border-bottom: 1px solid #1e293b;
}
.debt-table tr:last-child td { border-bottom: none; }
.debt-table .amount { font-weight: 600; color: #fb7185; text-align: right; }

/* ===== MINI BAR ROWS ===== */
.mini-bar-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid #1e293b;
}
.mini-bar-row:last-child { border-bottom: none; }
.mini-bar-label {
  font-size: 11px; color: #94a3b8; width: 70px;
  flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mini-bar-track {
  flex: 1; height: 6px; background: #0f172a;
  border-radius: 3px; overflow: hidden;
}
.mini-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  transition: width 0.8s ease;
}
.mini-bar-value {
  font-size: 11px; font-weight: 600; color: #f1f5f9;
  width: 70px; text-align: right; flex-shrink: 0;
}

/* ==============================================================
   TABLET (min-width: 600px)
   ============================================================== */
@media (min-width: 600px) {
  .navbar {
    flex-direction: row;
    align-items: center;
    padding: 14px 24px;
  }
  .container { padding: 20px 24px; }

  .kpi-row { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 11px; }

  .search-form { flex-wrap: nowrap; }
  .toolbar { flex-direction: row; justify-content: space-between; align-items: center; }
  .upload-form { width: auto; }

  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-card { padding: 28px; }
  .form-actions .btn { flex: none; }

  .charts-grid-2,
  .charts-grid-half { grid-template-columns: 1fr 1fr; }
  .chart-container { height: 260px; }

  .mini-bar-label { width: 90px; }
  .mini-bar-value { width: 80px; }
}

/* ==============================================================
   DESKTOP (min-width: 1024px)
   ============================================================== */
@media (min-width: 1024px) {
  .navbar { padding: 16px 40px; }
  .nav-links a { font-size: 13px; padding: 8px 16px; }
  .container { padding: 28px 40px; }

  .kpi-row {
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
  }
  .kpi-card { padding: 20px; }
  .kpi-value { font-size: 24px; }
  .kpi-label { font-size: 12px; }

  input, select, textarea { font-size: 14px; }

  /* Show table, hide mobile cards on desktop */
  .table-wrap { display: block; }
  .mobile-cards { display: none; }

  table { min-width: auto; }
  th { padding: 12px 14px; font-size: 11px; }
  td { padding: 10px 14px; font-size: 13px; }
  .ref-cell { max-width: 250px; }

  .charts-grid { grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }
  .charts-grid-half { grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
  .charts-grid-2 { grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 24px; }
  .chart-card { padding: 24px; }
  .chart-card h3 { font-size: 14px; }
  .chart-container { height: 280px; }

  .mini-bar-label { width: 100px; font-size: 12px; }
  .mini-bar-value { width: 90px; font-size: 12px; }

  .form-card { padding: 32px; }
}

/* ==============================================================
   WIDE DESKTOP (min-width: 1400px)
   ============================================================== */
@media (min-width: 1400px) {
  .kpi-value { font-size: 28px; }
}
