:root {
  --bg-dark: #f2ede0;
  --bg-card: rgba(255, 255, 255, 0.65);
  --border-color: rgba(58, 107, 71, 0.1);
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary: #10B981;
  --accent: #3b82f6;
  --warn: #d97706;
  --danger: #ef4444;
  --ok: #10b981;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Outfit', 'Tajawal', sans-serif;
  min-height: 100vh;
}
.rtl { direction: rtl; }
a { color: var(--primary); text-decoration: none; }

/* HEADER */
header {
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: rgba(245, 240, 230, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: 15px; }
.logo-badge {
  background: linear-gradient(135deg, var(--primary), #059669);
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: white;
}
.brand h1 { font-size: 22px; font-weight: 600; color: var(--text-main); }
.brand span { font-size: 13px; color: #059669; font-weight: 600; text-transform: uppercase; }

.header-actions { display: flex; align-items: center; gap: 15px; }
.nav-links { display: flex; gap: 10px; }
.btn {
  padding: 10px 20px; border-radius: 8px; border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.5); color: var(--text-main); text-decoration: none;
  font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px;
  cursor: pointer; transition: all 0.2s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.8); border-color: rgba(58, 107, 71, 0.2); }
.btn.active { background: rgba(16, 185, 129, 0.1); border-color: var(--primary); color: #047857; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #059669; border-color: #059669; }

/* CONTAINER & TITLE */
main { padding: 40px; max-width: 1400px; margin: 0 auto; }
.section-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 30px; }
.section-header h2 { font-size: 28px; font-weight: 600; color: var(--text-main); }
.section-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* GLASS CARD */
.glass-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 16px; padding: 25px; backdrop-filter: blur(12px);
  margin-bottom: 30px;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.04);
}
.glass-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; color: var(--text-main); }
.glass-card h3 .badge-pill { font-size: 11px; background: rgba(16,185,129,0.15); color: #047857; padding: 4px 8px; border-radius: 20px; font-weight: 600; }

/* KPI GRID */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.kpi { position: relative; }
.kpi-icon { font-size: 28px; color: var(--primary); margin-bottom: 15px; position: absolute; right: 20px; top: 20px; opacity: 0.25; }
.rtl .kpi-icon { right: auto; left: 20px; }
.kpi-title { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; font-weight: 600; }
.kpi-value-container { display: flex; align-items: baseline; gap: 8px; }
.kpi-value-container span:first-child { font-size: 32px; font-weight: 700; color: var(--text-main); }
.kpi-unit { color: var(--text-muted); font-size: 13px; }
.kpi-delta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.kpi.warn { border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.06); }
.kpi.warn .kpi-icon { color: var(--warn); }
.kpi.danger { border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.06); }
.kpi.danger .kpi-icon { color: var(--danger); }

/* ALERT BANNER */
.alert-banner {
  background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 12px; padding: 15px 20px; display: flex; align-items: center; gap: 15px;
  margin-bottom: 30px;
}
.alert-banner .icon { font-size: 24px; color: var(--warn); }
.alert-banner .text { flex: 1; }
.alert-banner h4 { font-size: 15px; font-weight: 600; color: #b45309; margin-bottom: 2px; }
.alert-banner p { font-size: 13px; color: var(--text-muted); }
.alert-banner button { background: var(--warn); border-color: var(--warn); color: #fff; font-weight: 600; padding: 6px 12px; border-radius: 6px; }
.alert-banner button:hover { background: #b45309; }

/* CHARTS ROW */
.charts-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-bottom: 30px; }
.chart-container { height: 280px; position: relative; width: 100%; }

/* TOOLBAR & INPUTS */
.toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.5); border: 1px solid var(--border-color);
  padding: 12px 20px; border-radius: 12px; margin-bottom: 15px;
}
.toolbar input, .toolbar select {
  background: rgba(255, 255, 255, 0.9); border: 1px solid var(--border-color);
  border-radius: 8px; padding: 8px 12px; color: var(--text-main); outline: none;
  font-family: inherit; font-size: 14px; min-width: 180px;
  transition: all 0.3s ease;
}
.toolbar input:focus, .toolbar select:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}
.toolbar .spacer { flex: 1; }
.toolbar .count-text { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* TABLES */
.table-responsive {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.4);
}
table.data-table {
  width: 100%; border-collapse: collapse; text-align: left; font-size: 14px;
}
.rtl table.data-table { text-align: right; }
table.data-table th, table.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-color); }
table.data-table th {
  background: rgba(0, 0, 0, 0.03); color: var(--text-muted);
  font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.5px; cursor: pointer; user-select: none;
}
table.data-table th:hover { background: rgba(0, 0, 0, 0.05); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: rgba(0, 0, 0, 0.015); }

table.data-table td.num { font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
.rtl table.data-table td.num { text-align: left; }
table.data-table td.pos { color: #047857; font-weight: 600; }
table.data-table td.neg { color: var(--danger); font-weight: 600; }
table.data-table td.zero { color: var(--text-muted); opacity: 0.6; }

/* BADGES & CHIPS */
.tag {
  display: inline-block; padding: 4px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.tag.mammals { background: rgba(139, 90, 28, 0.12); color: #c2410c; }
.tag.birds { background: rgba(30, 79, 139, 0.12); color: #1d4ed8; }
.tag.reptiles { background: rgba(30, 106, 42, 0.12); color: #15803d; }
.tag.other { background: rgba(139, 111, 71, 0.12); color: #be123c; }
.tag.unclassified { background: rgba(100, 116, 139, 0.12); color: #475569; }

.flag-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); margin-right: 8px; vertical-align: middle;
}
.rtl .flag-dot { margin-right: 0; margin-left: 8px; }
.flag-dot.has { background: var(--warn); }

.chips-row { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  background: rgba(0, 0, 0, 0.04); color: var(--text-muted);
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500;
  border: 1px solid rgba(0, 0, 0, 0.02);
}
.chip.balance, .chip.subtotal, .chip.negative { background: rgba(239, 68, 68, 0.1); color: #c026d3; }
.chip.sex, .chip.net { background: rgba(245, 158, 11, 0.1); color: #b45309; }

.sev-badge {
  display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.sev-high { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.sev-medium { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.sev-low { background: rgba(16, 185, 129, 0.12); color: #059669; }

/* AUDITOR CAT CARDS */
.cat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-bottom: 30px; }
.cat-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 16px; padding: 20px; border-left: 4px solid var(--warn);
  cursor: pointer; transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.02);
}
.rtl .cat-card { border-left: none; border-right: 4px solid var(--warn); }
.cat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
.cat-card.sev-high { border-left-color: var(--danger); }
.rtl .cat-card.sev-high { border-right-color: var(--danger); }
.cat-card.sev-low { border-left-color: var(--primary); }
.rtl .cat-card.sev-low { border-right-color: var(--primary); }
.cat-card .top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cat-card .name { font-weight: 600; font-size: 15px; color: var(--text-main); }
.cat-card .count { font-size: 24px; font-weight: 700; color: var(--text-main); }
.cat-card .desc { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.cat-card .fix { font-size: 11px; color: #047857; margin-top: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* MODAL BACKGROUND */
.modal-bg {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease; z-index: 200;
}
.modal-bg.show { opacity: 1; pointer-events: auto; }
.modal-box {
  background: #ffffff; border: 1px solid var(--border-color);
  border-radius: 16px; width: 90%; max-width: 550px; padding: 30px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.1); max-height: 90vh; overflow-y: auto;
  color: var(--text-main);
}
.modal-box h3 { font-size: 20px; font-weight: 600; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }
.modal-box .row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05); font-size: 14px;
}
.modal-box .row:last-of-type { border-bottom: none; }
.modal-box .row .k { color: var(--text-muted); }
.modal-box .row .v { font-weight: 500; color: var(--text-main); }
.modal-box .issue-list {
  background: rgba(239, 68, 68, 0.05); border: 1px solid rgba(239, 68, 68, 0.1);
  border-radius: 10px; padding: 15px; margin-top: 15px;
}
.modal-box .issue-list strong { color: #dc2626; font-size: 13px; display: block; margin-bottom: 8px; }
.modal-box .issue-list ul { padding-left: 20px; font-size: 13px; color: #b91c1c; }
.modal-box .issue-list li { margin-bottom: 4px; }
.modal-box button.close {
  width: 100%; margin-top: 20px; background: rgba(0, 0, 0, 0.05); border: none;
  padding: 12px; border-radius: 8px; color: var(--text-main); font-weight: 600; cursor: pointer;
  transition: all 0.2s ease;
}
.modal-box button.close:hover { background: rgba(0, 0, 0, 0.1); }

/* FORMS & TABS */
.form-tabs {
  display: flex; gap: 8px; background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-color); padding: 6px; border-radius: 12px;
  margin-bottom: 25px; overflow-x: auto;
}
.form-tab {
  flex: 1; min-width: 160px; padding: 10px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 600; color: var(--text-muted); background: transparent;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 8px; transition: all 0.2s ease;
}
.form-tab:hover { color: var(--text-main); }
.form-tab.active {
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.form-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px;
}
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
}
.form-field { display: flex; flex-direction: column; gap: 8px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.form-field label .req { color: var(--danger); margin-left: 4px; }
.rtl .form-field label .req { margin-left: 0; margin-right: 4px; }

.form-control {
  background: rgba(255, 255, 255, 0.85); border: 1px solid var(--border-color);
  border-radius: 8px; padding: 12px 15px; color: var(--text-main);
  font-family: inherit; font-size: 14px; transition: all 0.3s ease;
  width: 100%;
}
.form-control:focus {
  outline: none; border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}
textarea.form-control { min-height: 90px; resize: vertical; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 16px; padding-right: 40px;
}
.rtl select.form-control {
  background-position: left 15px center; padding-left: 40px; padding-right: 15px;
}
option { background: #ffffff; color: var(--text-main); }

/* Radio Grid for Forms */
.radio-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px;
}
.radio-card-lbl {
  border: 1px solid var(--border-color); border-radius: 10px; padding: 12px;
  cursor: pointer; font-weight: 500; display: flex; flex-direction: column;
  align-items: center; gap: 8px; font-size: 13px; background: rgba(255,255,255,0.6);
  text-align: center; color: var(--text-main); transition: all 0.2s ease;
}
.radio-card-lbl .e { font-size: 24px; }
.radio-cards input[type=radio] { display: none; }
.radio-cards label:has(input:checked) {
  border-color: var(--primary); background: rgba(16, 185, 129, 0.08);
  color: #047857; box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
}

.form-actions {
  display: flex; justify-content: flex-end; gap: 15px;
  margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--border-color);
}

/* Toast alert */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: rgba(4, 120, 87, 0.95); backdrop-filter: blur(8px);
  color: white; padding: 15px 30px; border-radius: 30px;
  display: flex; align-items: center; gap: 10px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  transform: translateX(-50%) translateY(100px); opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 1000;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
