* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Tahoma, sans-serif; background: #f0f2f5; color: #333; font-size: 14px; }

/* SIDEBAR */
#sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 220px;
  background: #1e3a5f; color: #fff; display: flex; flex-direction: column;
  z-index: 100;
}
#sidebar h1 { padding: 20px 15px; font-size: 16px; background: #152d4a; border-bottom: 1px solid #2a4f7a; }
#sidebar h1 span { display: block; font-size: 11px; color: #8ab4d4; margin-top: 4px; }
.nav-item {
  padding: 12px 20px; cursor: pointer; transition: background 0.2s;
  border-left: 3px solid transparent; font-size: 13px;
}
.nav-item:hover { background: #2a4f7a; }
.nav-item.active { background: #2a4f7a; border-left-color: #4a9edd; color: #fff; }
.nav-item .icon { margin-right: 8px; }
.nav-section { padding: 10px 15px 5px; font-size: 10px; color: #5a8ab0; text-transform: uppercase; letter-spacing: 1px; margin-top: 5px; }
#sidebar-bottom { margin-top: auto; padding: 15px; font-size: 11px; color: #5a8ab0; }
#backup-btn {
  margin: 0 15px 10px; padding: 10px; background: #27ae60; color: #fff;
  border: none; border-radius: 6px; cursor: pointer; font-size: 12px;
  width: calc(100% - 30px); transition: opacity 0.2s;
}
#backup-btn:hover { opacity: 0.85; }
#restore-btn {
  margin: 0 15px 10px; padding: 8px; background: #2980b9; color: #fff;
  border: none; border-radius: 6px; cursor: pointer; font-size: 12px;
  width: calc(100% - 30px); transition: opacity 0.2s;
}
#restore-btn:hover { opacity: 0.85; }

/* USER INFO & LOGOUT */
#user-info {
  margin: auto 15px 0;
  padding: 12px;
  background: rgba(255,255,255,0.07);
  border-radius: 8px;
  font-size: 12px;
}
#user-info-name {
  color: #8ab4d4;
  margin-bottom: 8px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#logout-btn {
  width: 100%; padding: 7px; background: rgba(231,76,60,0.75); color: #fff;
  border: none; border-radius: 5px; cursor: pointer; font-size: 11px;
  transition: background 0.2s;
}
#logout-btn:hover { background: #e74c3c; }

/* HIDE ADMIN-ONLY ELEMENTS FOR VIEWERS */
body.viewer-mode .admin-only { display: none !important; }

/* MAIN */
#main { margin-left: 220px; padding: 25px; min-height: 100vh; }
.page { display: none; }
.page.active { display: block; }

/* PAGE HEADER */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-title { font-size: 22px; font-weight: 600; color: #1e3a5f; }
.page-title span { font-size: 13px; color: #888; font-weight: normal; margin-left: 10px; }

/* CARDS */
.cards { display: flex; gap: 15px; margin-bottom: 25px; flex-wrap: wrap; }
.card {
  background: #fff; border-radius: 10px; padding: 20px 25px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08); flex: 1; min-width: 150px;
}
.card .label { font-size: 12px; color: #888; margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 700; color: #1e3a5f; }
.card .value.green { color: #27ae60; }
.card .value.red { color: #e74c3c; }
.card .value.orange { color: #e67e22; }
.card .value.blue { color: #2980b9; }

/* BUTTONS */
.btn {
  padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #1e3a5f; color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-secondary { background: #95a5a6; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* TABLES */
.table-wrap { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { background: #1e3a5f; color: #fff; padding: 11px 14px; text-align: left; font-size: 12px; font-weight: 600; }
td { padding: 10px 14px; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9ff; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* BADGES */
.badge { padding: 3px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-green  { background: #d5f5e3; color: #1e8449; }
.badge-red    { background: #fadbd8; color: #922b21; }
.badge-orange { background: #fdebd0; color: #935116; }
.badge-blue   { background: #d6eaf8; color: #1a5276; }
.badge-gray   { background: #eaecee; color: #555; }

/* MODAL */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 1000;
  justify-content: center; align-items: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 12px; padding: 30px;
  width: 550px; max-width: 95vw; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal h2 { font-size: 18px; margin-bottom: 20px; color: #1e3a5f; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* FORMS */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #ddd; border-radius: 6px;
  font-size: 13px; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: #1e3a5f; }
.form-row { display: flex; gap: 15px; }
.form-row .form-group { flex: 1; }

/* ALERT */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 15px; font-size: 13px; }
.alert-warning { background: #fef9e7; border: 1px solid #f9ca24; color: #7d6608; }
.alert-danger   { background: #fadbd8; border: 1px solid #e74c3c; color: #922b21; }
.alert-success  { background: #d5f5e3; border: 1px solid #27ae60; color: #1e8449; }

/* PROGRESS BAR */
.progress-bar { height: 8px; background: #eee; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.progress-fill.green  { background: #27ae60; }
.progress-fill.orange { background: #e67e22; }
.progress-fill.red    { background: #e74c3c; }

/* FILTER BAR */
.filter-bar { display: flex; gap: 10px; margin-bottom: 15px; align-items: center; flex-wrap: wrap; }
.filter-bar input, .filter-bar select {
  padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px;
}
.filter-bar input { flex: 1; min-width: 200px; }

/* TABS */
.tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 2px solid #e0e0e0; }
.tab {
  padding: 10px 20px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: #888; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.2s;
}
.tab.active { color: #1e3a5f; border-bottom-color: #1e3a5f; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* DETAIL PANEL */
.detail-panel {
  background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 20px; margin-top: 20px;
}
.detail-panel h3 { font-size: 16px; color: #1e3a5f; margin-bottom: 15px; }

/* SEARCH */
.search-box { position: relative; }
.search-box input { padding-left: 32px; }
.search-box::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; }

/* PLAFON WARNING */
.plafon-ok   { color: #27ae60; font-weight: 600; }
.plafon-warn { color: #e67e22; font-weight: 600; }
.plafon-over { color: #e74c3c; font-weight: 600; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 50px; color: #aaa; }
.empty-state .icon { font-size: 48px; margin-bottom: 15px; }

/* TOAST */
#toast {
  position: fixed; bottom: 30px; right: 30px; background: #1e3a5f; color: #fff;
  padding: 12px 20px; border-radius: 8px; font-size: 13px; z-index: 9999;
  transform: translateY(100px); transition: transform 0.3s; box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
#toast.show { transform: translateY(0); }
