:root {
  --bg-main: #0a0a0c;
  --bg-card: #121217;
  --bg-header: rgba(18, 18, 23, 0.8);
  --border: #22222a;
  --text-main: #e0e0e6;
  --text-muted: #8c8c9e;
  --primary: #3d8bff;
  --primary-glow: rgba(61, 139, 255, 0.2);
  --success: #00e676;
  --warning: #ffb300;
  --danger: #ff5252;
  --glass: blur(12px);
}

* { box-sizing: border-box; }
body { 
  font-family: 'Inter', system-ui, -apple-system, sans-serif; 
  margin: 0; background: var(--bg-main); color: var(--text-main); 
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}

header { 
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: var(--glass); background: var(--bg-header); 
  border-bottom: 1px solid var(--border); padding: 14px 24px; 
  display: flex; align-items: center; justify-content: space-between;
}
header h1 { margin: 0; font-size: 20px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }

nav { display: flex; gap: 10px; }
nav button { 
  border: 1px solid transparent; background: transparent; 
  color: var(--text-muted); padding: 8px 16px; border-radius: 12px; 
  cursor: pointer; font-weight: 500; transition: all 0.2s;
}
nav button:hover { background: rgba(255,255,255,0.05); color: #fff; }
nav button.active { background: var(--primary-glow); color: var(--primary); border-color: var(--primary); }

.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { 
  background: var(--bg-card); border: 1px solid var(--border); 
  border-radius: 20px; padding: 20px; transition: transform 0.2s;
}
.kpi:hover { transform: translateY(-4px); border-color: var(--primary); }
.kpi .label { color: var(--text-muted); font-size: 13px; font-weight: 600; text-transform: uppercase; }
.kpi .value { font-size: 28px; font-weight: 800; margin-top: 8px; color: #fff; }

.section-title { font-size: 20px; font-weight: 700; margin: 0 0 16px; display: flex; align-items: center; gap: 8px; }

.toolbar { 
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; 
  background: var(--bg-card); padding: 16px; border-radius: 16px; 
  border: 1px solid var(--border); margin-bottom: 20px;
}

.card { 
  background: var(--bg-card); border: 1px solid var(--border); 
  border-radius: 20px; padding: 20px; overflow: hidden;
}

input, select, textarea { 
  border: 1px solid var(--border); background: #08080a; 
  color: #fff; padding: 10px 14px; border-radius: 12px; 
  font-size: 14px; outline: none; transition: border-color 0.2s;
}
input:focus, select:focus { border-color: var(--primary); }
input::placeholder { color: #555; }

.btn { 
  border: 1px solid var(--border); background: #1a1a20; 
  color: #fff; padding: 10px 18px; border-radius: 12px; 
  cursor: pointer; font-size: 14px; font-weight: 600; 
  display: inline-flex; align-items: center; gap: 8px; transition: 0.2s;
}
.btn:hover { background: #25252d; border-color: #444; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { opacity: 0.9; }
.btn.danger { background: rgba(255, 82, 82, 0.1); border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }

table { width: 100%; border-collapse: separate; border-spacing: 0; }
/* MODALS */
.modal-overlay { 
    position:fixed; top:0; left:0; width:100%; height:100% ; 
    background:rgba(0,0,0,0.92); backdrop-filter:blur(15px); 
    display:flex; align-items:center; justify-content:center; 
    z-index:9000; padding: 20px; 
}
.modal { 
    background:var(--bg-card); border:2px solid var(--border); 
    border-radius:28px; width:98%; max-width:1200px; 
    max-height:92vh; overflow-y:auto; padding:40px; 
    position:relative; box-shadow:0 40px 100px rgba(0,0,0,0.9); 
    overscroll-behavior: contain;
}
.modal::-webkit-scrollbar { width: 8px; }
.modal::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }

.modal h3 { 
    margin-bottom: 35px; border-bottom: 2px solid var(--border); 
    padding-bottom: 20px; color: #fff; 
    font-size: 1.8rem; font-weight: 800; text-align: right;
}

.modal-section { margin-bottom: 40px; }
.modal-section .section-title { 
    display: block; color: var(--primary); 
    font-size: 0.95em; font-weight: 800; margin-bottom: 20px; 
    text-transform: uppercase; letter-spacing: 2px;
    border-right: 4px solid var(--primary); padding-right: 15px;
}

.grid { display:grid; gap:20px; }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.grid.three { grid-template-columns: repeat(3, 1fr); }

.detail-item { 
    background: #08080a; padding: 18px; 
    border-radius: 18px; border: 1px solid var(--border); 
    display: flex; flex-direction: column; gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.detail-item strong { color: var(--text-muted); font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-item span { font-weight: 600; color: #fff; font-size: 1.15em; word-break: break-all; }

/* UTILS */
.hidden { display:none !important; }
.muted { filter:brightness(0.5); font-size:0.9em; }
.badge { padding:4px 8px; border-radius:6px; font-size:0.8em; font-weight:600; }
.success { background:rgba(34,197,94,0.2); color:#4ade80; }
.warning { background:rgba(234,179,8,0.2); color:#facc15; }
.danger-badge { background:rgba(239,68,68,0.2); color:#f87171; }

.progress { width:100%; height:6px; background:rgba(255,255,255,0.08); border-radius:4px; overflow:hidden; margin-top:8px }
.progress .bar { height:100%; background:var(--success); width:0% }

.avatar-small { width:24px !important; height:24px !important; border-radius:50%; object-fit:cover; }
.avatar-large { width:64px !important; height:64px !important; border-radius:50%; object-fit:cover; border:2px solid var(--primary); }

.ref-list { margin-top: 10px; max-height: 150px; overflow-y: auto; font-size: 0.9em; background: rgba(0,0,0,0.2); border-radius: 8px; padding: 8px; }
.ref-item { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 4px 0; }
.ref-item:last-child { border: none; }

th { 
  text-align: right; padding: 14px; color: var(--text-muted); 
  font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border); 
}
td { padding: 14px; font-size: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

.login { 
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
}
.login .box { 
  width: min(400px, 92vw); background: var(--bg-card); 
  border: 1px solid var(--border); border-radius: 24px; padding: 32px;
}

#logout { margin-left: auto; color: var(--danger); }

/* RESPONSIVE BREAKPOINTS */
@media (max-width: 1200px) {
    .modal { width: 98%; padding: 30px; }
}

@media (max-width: 1000px) {
    .grid.three { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid.two, .grid.three { grid-template-columns: 1fr; }
    header { flex-direction: column; gap: 16px; }
    .modal { padding: 20px; border-radius: 20px; }
    .modal h3 { font-size: 1.4rem; margin-bottom: 25px; }
}

[dir="rtl"] .modal-section .section-title {
    text-align: right; margin-right: 0;
}
[dir="rtl"] .detail-item {
    text-align: right;
}
