/* Najat Power — UI (ALNAJAT identity: olive #31695C, gold #D79C38, white) */
@font-face { font-family: "Cairo"; font-style: normal; font-weight: 200 1000; font-display: swap; src: url("../fonts/cairo-arabic.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Cairo"; font-style: normal; font-weight: 200 1000; font-display: swap; src: url("../fonts/cairo-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --primary: #31695C; --primary-2: #3f8273; --accent: #D79C38; --accent-2: #e9b765;
  --bg: #0d1916; --bg2: #1b2a24; --panel: #13231e; --panel2: rgba(255,255,255,.04); --border: #24392f;
  --text: #e9f1ed; --muted: #93aaa1; --dim: #6f8780; --hover: rgba(255,255,255,.05); --input: #0f1e19;
  --ok: #2fb27c; --warn: #e3a21a; --bad: #e5484d; --info: #4ea3d8; --standby: #8a90a6; --offline: #e5484d; --unknown: #6f7f95;
  --pv: #D79C38; --bat: #2fb27c; --grid: #4ea3d8; --load: #e07a5f;
  --radius: 12px; --shadow: 0 8px 24px rgba(0,0,0,.25); --gap: 16px; --pad: 16px;
  --ease: cubic-bezier(.2,.8,.2,1);
  font-family: "Cairo", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 14px; font-feature-settings: "tnum" 1, "lnum" 1; color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f1f5f3; --bg2: #e3ebe7; --panel: #ffffff; --panel2: rgba(49,105,92,.05); --border: #d5e0da;
  --text: #15231e; --muted: #5d7269; --dim: #8a9a93; --hover: rgba(49,105,92,.07); --input: #f7faf8;
  --shadow: 0 8px 24px rgba(20,40,30,.08); color-scheme: light;
}
[data-density="compact"] { --gap: 10px; --pad: 10px; font-size: 13px; }
[data-radius="0"] { --radius: 2px; } [data-radius="8"] { --radius: 8px; } [data-radius="18"] { --radius: 18px; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); line-height: 1.55; -webkit-font-smoothing: antialiased; transition: background-color .35s, color .35s; overflow-x: hidden; }
[data-bg="gradient"] body { background: radial-gradient(1200px 700px at 85% -10%, color-mix(in srgb, var(--primary) 30%, transparent), transparent 60%),
  radial-gradient(900px 600px at -10% 110%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%), linear-gradient(160deg, var(--bg), var(--bg2)); background-attachment: fixed; }
[data-bg="mesh"] body { background: linear-gradient(135deg, var(--bg) 0%, color-mix(in srgb, var(--primary) 22%, var(--bg)) 50%, var(--bg2) 100%); background-attachment: fixed; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
h2 { font-size: 1.35em; } h3 { font-size: 1.05em; margin: 18px 0 10px; } h4 { font-size: .95em; margin: 14px 0 8px; color: var(--muted); }
.num, .n { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: .86em; } .big { font-size: 1.25em; } .center { text-align: center; }
.sp { flex: 1; } .hidden { display: none !important; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .col { display: flex; flex-direction: column; gap: 8px; }
.grid { display: grid; gap: var(--gap); } .g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.mt { margin-top: var(--gap); } .mb { margin-bottom: var(--gap); }
.c-ok { color: var(--ok); } .c-warn { color: var(--warn); } .c-bad { color: var(--bad); } .c-info { color: var(--info); } .c-acc { color: var(--accent); } .c-pv { color: var(--pv); } .c-bat { color: var(--bat); } .c-grid { color: var(--grid); } .c-load { color: var(--load); }

/* ---------- layout */
.app { display: flex; min-height: 100vh; }
.side { width: 250px; flex: none; background: color-mix(in srgb, var(--panel) 88%, transparent); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; backdrop-filter: blur(10px); z-index: 20; transition: width .25s var(--ease); }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 10px; }
.side .brand img { height: 40px; }
.side .brand .t { font-weight: 800; font-size: 1.15em; letter-spacing: .2px; }
.side .brand .s { font-size: .78em; color: var(--muted); margin-top: -3px; }
.nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--text); font-weight: 600; transition: background .15s, transform .15s; position: relative; }
.nav a:hover { background: var(--hover); text-decoration: none; transform: translateX(var(--nudge, -2px)); }
[dir="ltr"] .nav a:hover { --nudge: 2px; }
.nav a.active { background: color-mix(in srgb, var(--primary) 35%, transparent); color: #fff; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 60%, transparent); }
[data-theme="light"] .nav a.active { background: var(--primary); }
.nav a .ic { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; opacity: .9; }
.nav a .badge { margin-inline-start: auto; }
.nav .sec { font-size: .75em; color: var(--dim); padding: 12px 12px 4px; text-transform: uppercase; letter-spacing: .5px; }
.side .foot { margin-top: auto; padding: 12px 14px; font-size: .78em; color: var(--dim); border-top: 1px solid var(--border); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--panel) 70%, transparent); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 15; }
.top h1 { font-size: 1.2em; font-weight: 800; }
.top .userbox { display: flex; align-items: center; gap: 8px; }
.top .userbox .av { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; }
.content { padding: 22px; flex: 1; animation: fade .35s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.burger { display: none; }
@media (max-width: 960px) {
  .side { position: fixed; inset-inline-start: 0; transform: translateX(var(--off, 100%)); width: 260px; box-shadow: var(--shadow); }
  [dir="ltr"] .side { --off: -100%; }
  .side.open { transform: none; }
  .burger { display: inline-flex; }
  .content { padding: 14px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .top h1 { font-size: 1.05em; }
}
@media (max-width: 600px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .tiles { grid-template-columns: 1fr 1fr !important; } }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 19; display: none; } .overlay.show { display: block; }

/* ---------- components */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow); position: relative; }
.card .hd { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card .hd h3 { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--gap); }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; transition: transform .2s var(--ease), box-shadow .2s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile .l { color: var(--muted); font-size: .85em; } .tile .v { font-size: 1.7em; font-weight: 800; margin-top: 2px; line-height: 1.2; } .tile .u { font-size: .55em; color: var(--muted); margin-inline-start: 4px; font-weight: 600; }
.tile::after { content: ""; position: absolute; inset-inline-end: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: color-mix(in srgb, var(--tc, var(--primary)) 18%, transparent); }
.tile.ok { --tc: var(--ok); } .tile.bad { --tc: var(--bad); } .tile.warn { --tc: var(--warn); } .tile.pv { --tc: var(--pv); } .tile.bat { --tc: var(--bat); } .tile.grid { --tc: var(--grid); } .tile.load { --tc: var(--load); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel2); cursor: pointer; font-weight: 600; transition: all .15s; white-space: nowrap; }
.btn:hover { background: var(--hover); border-color: var(--primary-2); }
.btn.p { background: var(--primary); border-color: var(--primary); color: #fff; } .btn.p:hover { background: var(--primary-2); }
.btn.a { background: var(--accent); border-color: var(--accent); color: #1a1a1a; } .btn.a:hover { background: var(--accent-2); }
.btn.d { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); } .btn.d:hover { background: color-mix(in srgb, var(--bad) 15%, transparent); }
.btn.s { padding: 5px 10px; font-size: .88em; border-radius: 8px; } .btn.ic { padding: 7px; width: 34px; height: 34px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .85em; color: var(--muted); font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=date], input[type=search], input[type=tel], select, textarea {
  background: var(--input); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; outline: none; width: 100%; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
textarea { min-height: 80px; resize: vertical; }
.pw { position: relative; } .pw input { padding-inline-end: 40px; } .pw .eye { position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; cursor: pointer; color: var(--muted); padding: 4px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 40px; height: 22px; border-radius: 11px; background: var(--border); position: relative; transition: background .2s; cursor: pointer; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked { background: var(--primary); } .switch input:checked::after { transform: translateX(var(--sw, -18px)); } [dir="ltr"] .switch input:checked::after { --sw: 18px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .8em; font-weight: 700; background: var(--panel2); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge.bad, .badge.offline, .badge.fault { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.badge.online { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge.standby { color: var(--standby); } .badge.unknown { color: var(--unknown); } .badge.info { color: var(--info); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--unknown); }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); animation: pulse 2s infinite; }
.dot.offline, .dot.fault { background: var(--bad); } .dot.standby { background: var(--standby); } .dot.warn { background: var(--warn); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 9px 10px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t th { color: var(--muted); font-weight: 700; font-size: .85em; cursor: pointer; user-select: none; white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
table.t th.sorted::after { content: " ▲"; font-size: .75em; color: var(--accent); } table.t th.sorted.desc::after { content: " ▼"; }
table.t tr:hover td { background: var(--hover); }
table.t td.actions { white-space: nowrap; text-align: end; }
.tw { overflow: auto; max-height: 70vh; border-radius: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; } .kv .k { color: var(--muted); font-size: .9em; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: var(--gap); }
.toolbar input[type=search] { width: 240px; max-width: 100%; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .i { font-size: 2.4em; opacity: .5; }
.toast-wrap { position: fixed; bottom: 18px; inset-inline-start: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel); border: 1px solid var(--border); border-inline-start: 4px solid var(--primary); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); animation: fade .3s; max-width: 360px; }
.toast.ok { border-inline-start-color: var(--ok); } .toast.bad { border-inline-start-color: var(--bad); } .toast.warn { border-inline-start-color: var(--warn); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 14px; animation: fade .2s; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; width: min(640px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow); }
.modal.wide { width: min(980px, 100%); }
.modal .mh { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); } .modal .mh h3 { margin: 0; }
.modal .mb { padding: 18px; } .modal .mf { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); }
.spin { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 40px; }
.chart-box { position: relative; height: 280px; } .chart-box.sm { height: 180px; } .chart-box.lg { height: 360px; }
.dev-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; position: relative; overflow: hidden; }
.dev-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary-2); }
.dev-card .st { position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--unknown); }
.dev-card.online .st { background: var(--ok); } .dev-card.offline .st, .dev-card.fault .st { background: var(--bad); } .dev-card.standby .st { background: var(--standby); }
.dev-card .nm { font-weight: 800; font-size: 1.05em; display: flex; align-items: center; gap: 8px; }
.dev-card .sub { color: var(--muted); font-size: .82em; margin-top: 2px; }
.dev-card .vals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-top: 10px; }
.dev-card .vals div { font-size: .85em; color: var(--muted); } .dev-card .vals b { font-size: 1.1em; color: var(--text); display: block; }
.bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; } .bar i { display: block; height: 100%; background: var(--bat); transition: width .5s; }
.flow { display: grid; grid-template-columns: 1fr auto 1fr; grid-template-rows: auto auto auto; gap: 10px; align-items: center; padding: 10px 0; }
.flow .node { background: var(--panel2); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; text-align: center; min-width: 120px; }
.flow .node .ic { font-size: 1.6em; } .flow .node .v { font-weight: 800; font-size: 1.15em; } .flow .node .l { font-size: .8em; color: var(--muted); }
.flow .inv { grid-row: 1 / span 3; grid-column: 2; background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 60%, #000)); color: #fff; border-radius: 18px; padding: 18px 16px; text-align: center; min-width: 140px; box-shadow: var(--shadow); }
.flow .arrow { height: 3px; background: repeating-linear-gradient(90deg, var(--ac, var(--accent)) 0 10px, transparent 10px 18px); background-size: 28px 3px; animation: flowmove 1s linear infinite; border-radius: 2px; opacity: .9; }
.flow .arrow.rev { animation-direction: reverse; } .flow .arrow.off { animation: none; background: var(--border); }
@keyframes flowmove { to { background-position: 28px 0; } }
[dir="rtl"] .flow .arrow { animation-direction: reverse; } [dir="rtl"] .flow .arrow.rev { animation-direction: normal; }
.ctrl-row { display: grid; grid-template-columns: 1fr 220px auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 700px) { .ctrl-row { grid-template-columns: 1fr; } }
.raw-list { columns: 2; column-gap: 24px; } .raw-list div { break-inside: avoid; display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--border); font-size: .9em; }
@media (max-width: 700px) { .raw-list { columns: 1; } }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: .85em; cursor: pointer; background: var(--panel2); }
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.res { height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; } .res i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 22px; padding: 30px 28px; box-shadow: 0 30px 60px rgba(0,0,0,.35); animation: fade .5s var(--ease); }
.login .logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 22px; }
.login .logo img { height: 64px; }
.login .logo h2 { font-size: 1.4em; font-weight: 900; letter-spacing: .3px; }
.login .logo .s { color: var(--muted); font-size: .9em; }
.login .err { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); border-radius: 10px; padding: 8px 12px; font-size: .9em; }
.login .sig { text-align: center; color: var(--dim); font-size: .78em; margin-top: 18px; }
.blob { position: fixed; border-radius: 50%; filter: blur(60px); opacity: .5; z-index: -1; animation: drift 18s ease-in-out infinite alternate; }
.blob.a { width: 420px; height: 420px; background: var(--primary); top: -120px; inset-inline-end: -100px; }
.blob.b { width: 360px; height: 360px; background: var(--accent); bottom: -120px; inset-inline-start: -80px; animation-delay: -8s; }
@keyframes drift { from { transform: translate(0,0) scale(1); } to { transform: translate(40px, 30px) scale(1.15); } }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; } ::-webkit-scrollbar-thumb:hover { background: var(--dim); }
.print-only { display: none; }
@media print { .side, .top, .toolbar, .btn { display: none !important; } .content { padding: 0; } .print-only { display: block; } }
