:root {
  --primary: #1b3a6b;
  --primary-light: #2c5aa0;
  --primary-dark: #0f2340;
  --accent: #e8f0fe;
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --topbar-height: 60px;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --info: #17a2b8;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-500: #adb5bd;
  --gray-700: #495057;
  --gray-900: #212529;
  --white: #ffffff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --radius: 8px;
}

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

body {
  font-family: "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-100);
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--gray-200);
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .menu-label,
.sidebar.collapsed .menu-text {
  display: none;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.menu-section {
  padding: 8px 16px 4px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--gray-500);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.sidebar.collapsed .menu-section {
  text-align: center;
  padding: 8px 4px 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  color: var(--gray-700);
  text-decoration: none;
  border-radius: 0;
  transition: all 0.15s;
  position: relative;
  white-space: nowrap;
}

.menu-item:hover {
  background: var(--accent);
  color: var(--primary);
}

.menu-item.active {
  background: var(--accent);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

.menu-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.menu-text {
  font-size: 14px;
}

.sidebar-toggle {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--gray-200);
  cursor: pointer;
  color: var(--gray-500);
  transition: color 0.15s;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  color: var(--primary);
}

/* ===== TOP BAR ===== */
.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 90;
  transition: left 0.2s ease;
  gap: 16px;
}

.sidebar.collapsed ~ .topbar {
  left: var(--sidebar-collapsed);
}

.topbar-search {
  flex: 1;
  max-width: 400px;
}

.topbar-search input {
  width: 100%;
  padding: 8px 16px;
  border: 1px solid var(--gray-300);
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.topbar-search input:focus {
  border-color: var(--primary-light);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--gray-700);
}

.topbar-user .avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

/* ===== MAIN CONTENT ===== */
.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 24px;
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left 0.2s ease;
}

.sidebar.collapsed ~ .main {
  margin-left: var(--sidebar-collapsed);
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
}

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  background: var(--primary);
}

.card-body {
  padding: 20px;
}

/* ===== STAT WIDGETS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-icon.green {
  background: #d4edda;
  color: var(--success);
}
.stat-icon.yellow {
  background: #fff3cd;
  color: var(--warning);
}
.stat-icon.red {
  background: #f8d7da;
  color: var(--danger);
}
.stat-icon.blue {
  background: #d1ecf1;
  color: var(--info);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
}
.stat-label {
  font-size: 13px;
  color: var(--gray-500);
}

/* ===== TABLES ===== */
.table-card {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 14px;
}

table tbody tr:hover {
  background: var(--gray-100);
}

/* ===== COLLAPSIBLE SECTIONS (calc form) ===== */
.section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.section-header {
  background: var(--primary);
  color: var(--white);
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.section-header:hover {
  background: var(--primary-light);
}

.section-header .chevron {
  transition: transform 0.2s;
  font-size: 20px;
}

.section-header[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}

.section-body {
  padding: 20px;
}

/* ===== FORM ELEMENTS ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
}

.form-group input,
.form-group select {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  overflow: hidden;
  width: fit-content;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: var(--white);
  cursor: pointer;
  font-size: 14px;
  color: var(--gray-700);
  transition: all 0.15s;
  border-right: 1px solid var(--gray-300);
}

.tab-btn:last-child {
  border-right: none;
}
.tab-btn.active {
  background: var(--primary);
  color: var(--white);
}
.tab-btn:hover:not(.active) {
  background: var(--accent);
}

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--primary-light);
}
.btn-success {
  background: var(--success);
  color: var(--white);
}
.btn-success:hover {
  background: #218838;
}
.btn-outline {
  background: var(--white);
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover {
  background: var(--accent);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ===== BADGES ===== */
.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: #d4edda;
  color: #155724;
}
.badge-warning {
  background: #fff3cd;
  color: #856404;
}
.badge-danger {
  background: #f8d7da;
  color: #721c24;
}
.badge-info {
  background: #d1ecf1;
  color: #0c5460;
}
.badge-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

/* ===== RESULTS PANEL (right side, calc page) ===== */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

.results-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
}

.result-row:hover {
  background: var(--gray-100);
}

.result-company {
  font-weight: 500;
}

.result-price {
  font-weight: 700;
  color: var(--success);
  font-size: 16px;
}
.result-error {
  color: var(--danger);
  font-size: 13px;
}
.result-pending {
  color: var(--gray-500);
  font-size: 13px;
}

/* ===== LOGIN PAGE ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(
    135deg,
    var(--primary-dark),
    var(--primary-light)
  );
}

.login-card {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.login-card h1 {
  text-align: center;
  color: var(--primary);
  margin-bottom: 8px;
  font-size: 24px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--gray-500);
  margin-bottom: 32px;
  font-size: 14px;
}

.login-card .form-group {
  margin-bottom: 16px;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 15px;
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 16px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .calc-layout {
    grid-template-columns: 1fr;
  }
  .results-panel {
    position: static;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }
  .sidebar .logo-text,
  .sidebar .menu-text,
  .sidebar .menu-section {
    display: none;
  }
  .topbar {
    left: var(--sidebar-collapsed);
  }
  .main {
    margin-left: var(--sidebar-collapsed);
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}
