/* ================= Sweetlicious Dashboard — RTL dark theme ================= */

:root {
  --bg:        #0e1015;
  --bg-2:      #12151c;
  --panel:     #161a23;
  --panel-2:   #1c2130;
  --line:      #262c3a;
  --line-soft: #1e2432;
  --text:      #e9ecf3;
  --muted:     #94a0b6;
  --muted-2:   #6f7b91;
  --accent:    #d9a566;
  --accent-2:  #f0c58c;
  --accent-dim:rgba(217,165,102,.14);
  --green:     #3fbf83;
  --blue:      #5aa9f0;
  --red:       #f0616a;
  --amber:     #e5b04b;
  --purple:    #a78bfa;
  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 10px 30px rgba(0,0,0,.45);
  --font:      "Segoe UI", "Noto Sans Arabic", "Dubai", Tahoma, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.35; }
p { margin: 0 0 .6em; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent-2); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1 1 auto; min-width: 0; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; direction: ltr; unicode-bidi: embed; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3143; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #37405a; }

/* ================= Login ================= */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(217,165,102,.13), transparent 60%),
    radial-gradient(700px 420px at 10% 110%, rgba(90,169,240,.08), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 26px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card h1 { font-size: 24px; margin-top: 12px; letter-spacing: .3px; }
.login-card p { margin-bottom: 22px; font-size: 13.5px; }
.login-card label { display: block; text-align: start; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.login-card input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  margin-bottom: 16px;
  outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-error { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 10px; }

.brand-mark {
  width: 54px; height: 54px;
  margin: 0 auto;
  display: grid; place-items: center;
  border-radius: 16px;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  color: #171a22;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: .5px;
}
.brand-mark.sm { width: 38px; height: 38px; border-radius: 11px; font-size: 15px; margin: 0; }

/* ================= App shell ================= */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--bg-2);
  border-inline-start: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted-2); }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1 1 auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  text-align: start;
  font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent-2); font-weight: 650; }
.nav-ico { width: 20px; text-align: center; font-size: 14px; opacity: .95; }
.nav-badge {
  margin-inline-start: auto;
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11.5px;
  min-width: 22px;
  text-align: center;
}
.nav-item.active .nav-badge { background: rgba(0,0,0,.25); color: var(--accent-2); }
.nav-badge:empty { display: none; }
.nav-badge.red { background: rgba(240,97,106,.18); color: #ff9095; border: 1px solid rgba(240,97,106,.32); }
.nav-item.active .nav-badge.red { color: #ff9095; }

.side-foot { padding: 12px 14px 16px; border-top: 1px solid var(--line-soft); }
.wa-mini { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.wa-mini .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted-2); flex: 0 0 auto; }
.wa-mini.on .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(63,191,131,.18); }
.wa-mini.off .dot { background: var(--red); box-shadow: 0 0 0 3px rgba(240,97,106,.16); }
.side-version { font-size: 11px; color: var(--muted-2); margin-top: 8px; }

.scrim { display: none; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  background: rgba(14,16,21,.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar h2 { font-size: 18px; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.view { display: none; padding: 20px 22px 60px; flex-direction: column; gap: 16px; }
.view.active { display: flex; }

/* ================= Controls ================= */

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: #232a3b; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(140deg, var(--accent-2), var(--accent)); border-color: transparent; color: #171a22; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel); }
.btn.danger { background: transparent; border-color: rgba(240,97,106,.4); color: #ff8d94; }
.btn.danger:hover { background: rgba(240,97,106,.12); }
.btn.block { width: 100%; padding: 11px; }
.btn.xs { padding: 5px 10px; font-size: 12.5px; }

.icon-btn {
  background: transparent; border: 1px solid var(--line);
  color: var(--text); border-radius: var(--radius-sm);
  width: 36px; height: 36px; cursor: pointer;
}
.link-btn { background: none; border: 0; color: var(--accent-2); cursor: pointer; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.only-mobile { display: none; }

.input {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  outline: none;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
select.input { cursor: pointer; }
textarea.input { resize: vertical; line-height: 1.7; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 42px; height: 24px; border-radius: 20px;
  background: #2c3346; border: 1px solid var(--line);
  position: relative; transition: background .18s;
  flex: 0 0 auto;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: transform .18s, background .18s;
}
.switch input:checked + .track { background: rgba(63,191,131,.28); border-color: rgba(63,191,131,.5); }
.switch input:checked + .track::after { background: var(--green); transform: translateX(-18px); }

/* ================= Panels / cards ================= */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.panel.no-pad { padding: 0; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.panel:not(.no-pad) > .panel-head { padding: 0 0 12px; margin-bottom: 12px; }
.panel-head h3 { font-size: 15px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; inset-block-start: 0; inset-inline-start: 0;
  width: 3px; height: 100%; background: var(--accent); opacity: .8;
}
.stat.green::before { background: var(--green); }
.stat.blue::before { background: var(--blue); }
.stat.red::before { background: var(--red); }
.stat.amber::before { background: var(--amber); }
.stat.purple::before { background: var(--purple); }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: .2px; margin-top: 2px; }
.stat-sub { font-size: 12px; color: var(--muted-2); }

.empty { padding: 26px 18px; text-align: center; color: var(--muted-2); font-size: 13.5px; }

/* ================= Tables ================= */

.table-wrap { width: 100%; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 620px; }
table.tbl th {
  text-align: start; font-weight: 600; font-size: 12.5px; color: var(--muted);
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: var(--panel-2); white-space: nowrap; position: sticky; top: 0;
}
table.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tbody tr:hover { background: rgba(255,255,255,.025); }
table.tbl tr.clickable { cursor: pointer; }
table.tbl td.num { direction: ltr; text-align: start; unicode-bidi: embed; }
table.tbl .cell-input {
  background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 6px 8px; width: 100%; min-width: 90px; outline: none;
}
table.tbl .cell-input:focus { border-color: var(--accent); }
table.tbl .cell-input.w-sm { min-width: 62px; }
table.tbl .cell-input.w-lg { min-width: 190px; }
table.tbl input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
tr.dirty td { background: rgba(217,165,102,.07); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.green  { background: rgba(63,191,131,.14); color: #6fdcaa; border-color: rgba(63,191,131,.28); }
.badge.blue   { background: rgba(90,169,240,.14); color: #8cc6fa; border-color: rgba(90,169,240,.28); }
.badge.amber  { background: rgba(229,176,75,.14); color: #f0ca7a; border-color: rgba(229,176,75,.3); }
.badge.red    { background: rgba(240,97,106,.14); color: #ff9095; border-color: rgba(240,97,106,.3); }
.badge.purple { background: rgba(167,139,250,.14); color: #c4b1ff; border-color: rgba(167,139,250,.3); }
.badge.gold   { background: var(--accent-dim); color: var(--accent-2); border-color: rgba(217,165,102,.3); }

/* ================= Lists / feed ================= */

.mini-list { display: flex; flex-direction: column; }
.mini-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.mini-row:last-child { border-bottom: 0; }
.mini-row:hover { background: rgba(255,255,255,.03); }
.mini-main { min-width: 0; flex: 1 1 auto; }
.mini-title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-sub { font-size: 12px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.feed { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; }
.feed-row { display: flex; gap: 10px; align-items: baseline; padding: 7px 2px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.feed-row:last-child { border-bottom: 0; }
.feed-type { flex: 0 0 auto; }
.feed-detail { flex: 1 1 auto; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-time { flex: 0 0 auto; font-size: 11.5px; color: var(--muted-2); }

/* ================= Chat ================= */

.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 130px); min-height: 460px; }
.conv-col { display: flex; flex-direction: column; overflow: hidden; }
.conv-search { padding: 12px; border-bottom: 1px solid var(--line-soft); }
.conv-search .input { width: 100%; }
.conv-list { overflow-y: auto; flex: 1 1 auto; }
.conv-item {
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
  display: flex; gap: 10px; align-items: flex-start;
}
.conv-item:hover { background: rgba(255,255,255,.03); }
.conv-item.active { background: var(--accent-dim); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--panel-2); color: var(--accent-2); border: 1px solid var(--line);
}
.conv-meta { min-width: 0; flex: 1 1 auto; }
.conv-name { font-size: 13.5px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.conv-name span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-last { font-size: 12px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--muted-2); flex: 0 0 auto; }

.chat-col { display: flex; flex-direction: column; overflow: hidden; }
.chat-head {
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 60px;
}
.chat-head .empty { padding: 0; }
.chat-title { font-weight: 650; font-size: 14.5px; }
.chat-sub { font-size: 12px; color: var(--muted-2); }
.chat-head-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.chat-body {
  flex: 1 1 auto; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
  background:
    radial-gradient(600px 300px at 100% 0%, rgba(217,165,102,.05), transparent 60%),
    var(--panel);
}
.bubble {
  max-width: min(74%, 560px);
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
}
.bubble .b-time { display: block; font-size: 10.5px; color: var(--muted-2); margin-top: 4px; }
.bubble.user { align-self: flex-start; background: var(--panel-2); border-start-start-radius: 4px; }
.bubble.bot  { align-self: flex-end; background: rgba(217,165,102,.13); border-color: rgba(217,165,102,.25); border-start-end-radius: 4px; }
.bubble.sys  { align-self: center; background: transparent; border: 1px dashed var(--line); color: var(--muted-2); font-size: 12px; max-width: 90%; }

.chat-send { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line-soft); }

/* ================= Prompts ================= */

.prompt-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.prompt-list-col { max-height: calc(100vh - 130px); display: flex; flex-direction: column; overflow: hidden; }
.prompt-list { overflow-y: auto; }
.prompt-group { padding: 9px 16px; font-size: 11.5px; color: var(--muted-2); background: var(--panel-2); border-bottom: 1px solid var(--line-soft); letter-spacing: .4px; }
.prompt-item { padding: 11px 16px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.prompt-item:hover { background: rgba(255,255,255,.03); }
.prompt-item.active { background: var(--accent-dim); }
.prompt-item .pi-title { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.prompt-item .pi-desc { font-size: 12px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.pi-dot.off { background: var(--muted-2); }
.prompt-editor-col { min-height: 420px; }
#prompt-editor textarea {
  width: 100%; min-height: 46vh; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; line-height: 1.85; font-size: 14px; outline: none;
}
#prompt-editor textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.editor-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }

/* ================= Settings ================= */

.settings-form { display: flex; flex-direction: column; gap: 16px; padding-bottom: 20px; }
.set-group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.set-group h3 { font-size: 15px; margin-bottom: 4px; }
.set-group > .gdesc { font-size: 12.5px; color: var(--muted-2); margin-bottom: 14px; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted-2); }
.field .input { width: 100%; }
.field.bool { justify-content: flex-end; }
.save-bar {
  position: sticky; bottom: 0;
  display: flex; gap: 12px; align-items: center;
  padding: 12px 16px;
  background: rgba(18,21,28,.94);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ================= WhatsApp ================= */

.wa-status { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.wa-light { width: 14px; height: 14px; border-radius: 50%; background: var(--muted-2); }
.wa-light.on { background: var(--green); box-shadow: 0 0 0 5px rgba(63,191,131,.14); }
.wa-light.off { background: var(--red); box-shadow: 0 0 0 5px rgba(240,97,106,.12); }
.qr-raw {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px;
  direction: ltr; text-align: left; overflow-wrap: anywhere; white-space: pre-wrap;
  max-height: 220px; overflow-y: auto; color: var(--accent-2);
}
.steps { margin: 0; padding-inline-start: 22px; color: var(--muted); font-size: 13.5px; }
.steps li { margin-bottom: 5px; }

/* رمز الربط: بطاقة بيضاء إلزامية — ماسح واتساب لا يقرأ رمزاً على خلفية داكنة */
.qr-wrap {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px; margin-top: 14px;
}
.qr-card {
  flex: 0 0 auto;
  background: #ffffff;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  line-height: 0;
}
.qr-card img {
  display: block; width: 280px; height: 280px; max-width: 100%;
  border-radius: 6px; image-rendering: pixelated;
}
.qr-card-empty {
  width: 308px; height: 308px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 1px dashed var(--line); box-shadow: none;
}
.qr-wait { line-height: 1.7; font-size: 13px; color: var(--muted-2); text-align: center; padding: 0 18px; }
.qr-guide { flex: 1 1 260px; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.qr-guide .steps { font-size: 14px; }
.qr-guide p { margin: 0; }
.qr-details { border-top: 1px solid var(--line-soft); padding-top: 10px; }
.qr-details summary { cursor: pointer; font-size: 12.5px; color: var(--muted-2); }
.qr-details summary:hover { color: var(--muted); }
.qr-details .qr-raw { margin-top: 8px; max-height: 140px; }

/* الجلسة مربوطة */
.wa-linked { display: flex; align-items: flex-start; gap: 14px; }
.wa-linked-mark {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(63,191,131,.14); border: 1px solid rgba(63,191,131,.35);
  color: var(--green); font-size: 19px; line-height: 1;
}
.wa-linked-id { font-size: 17px; font-weight: 650; color: var(--accent-2); margin-top: 2px; }

@media (max-width: 640px) {
  .qr-card img { width: 240px; height: 240px; }
  .qr-card-empty { width: 100%; height: 240px; }
}

/* ================= Guard (الحماية) ================= */

#guard-panel { display: flex; flex-direction: column; gap: 16px; }

.warmup-banner {
  background: linear-gradient(140deg, rgba(63,191,131,.16), rgba(63,191,131,.06));
  border: 1px solid rgba(63,191,131,.32);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13.5px;
  color: #8ee3b8;
}

.guard-top { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: stretch; }
.gauge-panel { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.guard-ctl h3 { font-size: 15px; margin-bottom: 4px; }

.gauge {
  --pct: 0;
  --gc: var(--green);
  width: 154px; height: 154px; flex: 0 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--gc) calc(var(--pct) * 1%), var(--line-soft) 0);
  box-shadow: inset 0 0 0 1px var(--line);
}
.gauge.safe     { --gc: var(--green); }
.gauge.warning  { --gc: var(--amber); }
.gauge.critical { --gc: var(--red); }
.gauge-inner {
  width: 120px; height: 120px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line);
  display: grid; place-items: center; align-content: center;
}
.gauge-num { font-size: 34px; font-weight: 700; line-height: 1.15; direction: ltr; }
.gauge.safe .gauge-num     { color: #6fdcaa; }
.gauge.warning .gauge-num  { color: #f0ca7a; }
.gauge.critical .gauge-num { color: #ff9095; }
.gauge-max { font-size: 11.5px; color: var(--muted-2); }
.gauge-info { flex: 1 1 260px; min-width: 0; }
.gauge-info p { margin-top: 8px; margin-bottom: 0; }

.meter {
  height: 6px; border-radius: 6px; background: var(--line-soft);
  overflow: hidden; margin: 8px 0 6px;
}
.meter > span { display: block; height: 100%; border-radius: 6px; background: var(--accent); transition: width .25s; }
.meter.green > span { background: var(--green); }
.meter.amber > span { background: var(--amber); }
.meter.red   > span { background: var(--red); }

.switch.warn input:checked + .track { background: rgba(240,97,106,.28); border-color: rgba(240,97,106,.5); }
.switch.warn input:checked + .track::after { background: var(--red); }

.pill.risk.safe     { color: #6fdcaa; border-color: rgba(63,191,131,.35); }
.pill.risk.warning  { color: #f0ca7a; border-color: rgba(229,176,75,.4); }
.pill.risk.critical { color: #ff9095; border-color: rgba(240,97,106,.45); background: rgba(240,97,106,.12); }

/* ================= Alerts (التنبيهات) ================= */

.alerts-sum { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.alert-list { display: flex; flex-direction: column; gap: 12px; }
.alert-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--muted-2);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.alert-card.info     { border-inline-start-color: var(--blue); }
.alert-card.warning  { border-inline-start-color: var(--amber); }
.alert-card.critical { border-inline-start-color: var(--red); }
.alert-card.unread { background: linear-gradient(140deg, rgba(217,165,102,.07), transparent 70%); }
.al-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.al-title { font-weight: 650; font-size: 14.5px; flex: 1 1 auto; min-width: 0; }
.al-time { font-size: 11.5px; color: var(--muted-2); flex: 0 0 auto; }
.al-body {
  margin-top: 8px; font-size: 13.5px; color: var(--muted);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.al-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line-soft);
}
.al-foot .btn { margin-inline-start: auto; }

/* ================= Drawer ================= */

.drawer { position: fixed; inset: 0; z-index: 80; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); animation: fade .18s ease; }
.drawer-panel {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  width: min(560px, 100%);
  background: var(--panel);
  border-inline-end: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-y: auto;
  animation: slide-in .2s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { opacity: .3; transform: scale(.985); } }
.drawer-close {
  position: sticky; top: 10px; inset-inline-start: 10px; float: inline-start;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  width: 32px; height: 32px; border-radius: 9px; cursor: pointer; margin: 10px;
}
.drawer-close:hover { color: var(--text); }
.drawer-body { padding: 12px 22px 40px; }
.dr-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.dr-head h3 { font-size: 19px; }
.dr-section { margin-top: 20px; }
.dr-section > h4 { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.line-list { display: flex; flex-direction: column; gap: 6px; }
.line-item {
  display: flex; justify-content: space-between; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13.5px;
}
.totals { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; font-size: 13.5px; }
.totals .t-row { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .t-row.grand { font-size: 16px; font-weight: 700; color: var(--accent-2); border-top: 1px solid var(--line-soft); margin-top: 6px; padding-top: 8px; }
.msg-log { display: flex; flex-direction: column; gap: 8px; }
.msg-log .m {
  background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13.5px; white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-log .m .m-head { font-size: 11.5px; color: var(--muted-2); margin-bottom: 3px; display: flex; justify-content: space-between; gap: 10px; }
.dr-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

/* ================= Toasts ================= */

.toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px;
  box-shadow: var(--shadow); animation: fade .16s ease; max-width: 340px;
}
.toast.ok { border-inline-start-color: var(--green); }
.toast.err { border-inline-start-color: var(--red); }

.pill {
  font-size: 12.5px; padding: 4px 11px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.pill.on { color: #6fdcaa; border-color: rgba(63,191,131,.35); }
.pill.off { color: #ff9095; border-color: rgba(240,97,106,.35); }

/* ================= Responsive ================= */

@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 270px 1fr; }
  .prompt-layout { grid-template-columns: 270px 1fr; }
  .guard-top { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .only-mobile { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    transform: translateX(100%); transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .view { padding: 14px 14px 60px; }
  .topbar { padding: 12px 14px; }
  .chat-layout, .prompt-layout { grid-template-columns: 1fr; height: auto; }
  .conv-col { max-height: 44vh; }
  .chat-col { height: 68vh; }
  .prompt-list-col { max-height: 40vh; }
  .kv { grid-template-columns: 108px 1fr; }
  .topbar-actions .pill { display: none; }
  .gauge { width: 128px; height: 128px; }
  .gauge-inner { width: 100px; height: 100px; }
  .gauge-num { font-size: 28px; }
  .al-foot .btn { margin-inline-start: 0; }
}
