@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root{
  --bg: #0a0c0f; --surface: #12161b; --surface-2: #191f26;
  --border: #262e39; --border-soft: #1a2029;
  --text: #e9edf2; --text-dim: #8c98a8; --text-faint: #566072;
  --accent: #d9a441; --accent-soft: #d9a44122;
  --accent-2: #45d6c4; --accent-2-soft: #45d6c422;
  --danger: #e6685f; --danger-soft: #e6685f1c;
  --ok: #6fcf7f; --ok-soft: #6fcf7f1c;
}
@media (prefers-color-scheme: light){
  :root:not([data-theme="dark"]){
    --bg: #f1f3f6; --surface: #ffffff; --surface-2: #f3f5f8;
    --border: #d7dce3; --border-soft: #e3e7ec;
    --text: #171b21; --text-dim: #5b6472; --text-faint: #8e97a3;
    --accent: #a3711b; --accent-soft: #a3711b1a;
    --accent-2: #128a80; --accent-2-soft: #128a801a;
    --danger: #c1362d; --danger-soft: #c1362d14;
    --ok: #1e8a3d; --ok-soft: #1e8a3d14;
  }
}

*{ box-sizing:border-box; }
html{ background:var(--bg); }
body{
  margin:0; background:var(--bg); color:var(--text);
  direction:rtl; text-align:right;
  font-family:"IBM Plex Sans Arabic","Segoe UI",Tahoma,sans-serif;
  line-height:1.65; -webkit-font-smoothing:antialiased;
}
.mono{ font-family:"IBM Plex Mono",ui-monospace,monospace; }
h1,h2,h3{ margin:0; font-weight:700; }
p{ margin:0; }
a{ color:inherit; }

.wrap{ max-width:1040px; margin:0 auto; padding:0 22px; }

header.nav{ position:sticky; top:0; z-index:20; background:color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter:blur(10px); border-bottom:1px solid var(--border-soft); }
.nav-row{ display:flex; align-items:center; justify-content:space-between; gap:16px; padding:13px 0; flex-wrap:wrap; }
.brand{ display:flex; align-items:center; gap:10px; text-decoration:none; }
.brand-mark{ width:32px; height:32px; border:1.5px solid var(--accent); border-radius:7px; display:flex; align-items:center; justify-content:center; font-family:"IBM Plex Mono",monospace; font-weight:600; font-size:12px; color:var(--accent); background:var(--accent-soft); flex-shrink:0; }
.brand-name{ font-weight:700; font-size:14px; }
.brand-name span{ display:block; font-family:"IBM Plex Mono",monospace; font-weight:400; font-size:10px; color:var(--text-faint); letter-spacing:.04em; }
nav.links{ display:flex; gap:18px; }
nav.links a{ font-size:13px; color:var(--text-dim); text-decoration:none; padding-bottom:2px; border-bottom:1px solid transparent; }
nav.links a[aria-current="page"]{ color:var(--text); border-color:var(--accent); }
nav.links a:hover{ color:var(--accent); }
.btn-ghost-sm{ font-family:"IBM Plex Mono",monospace; font-size:11.5px; background:transparent; border:1px solid var(--border); color:var(--text-dim); border-radius:5px; padding:5px 10px; cursor:pointer; }
.btn-ghost-sm:hover{ border-color:var(--danger); color:var(--danger); }

.panel{ position:relative; background:var(--surface); border:1px solid var(--border); border-radius:6px; padding:22px; }
.panel::before,.panel::after{ content:""; position:absolute; width:14px; height:14px; pointer-events:none; }
.panel::before{ top:-1px; right:-1px; border-top:2px solid var(--accent); border-right:2px solid var(--accent); }
.panel::after{ bottom:-1px; left:-1px; border-bottom:2px solid var(--accent-2); border-left:2px solid var(--accent-2); }

.login-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; }
.login-card{ width:100%; max-width:360px; }

.field{ display:flex; flex-direction:column; gap:6px; margin-bottom:14px; }
.field label{ font-size:12.5px; color:var(--text-dim); }
.field .hint{ font-size:11.5px; color:var(--text-faint); }
input, select, textarea{
  font:inherit; font-size:14px; color:var(--text); background:var(--surface-2);
  border:1px solid var(--border); border-radius:6px; padding:10px 12px; outline:none; width:100%;
}
input:focus, select:focus, textarea:focus{ border-color:var(--accent-2); box-shadow:0 0 0 3px var(--accent-2-soft); }
textarea{ resize:vertical; min-height:90px; font-family:inherit; }
textarea.mono-area{ font-family:"IBM Plex Mono",monospace; font-size:13px; min-height:220px; direction:ltr; text-align:left; }
label.checkbox{ display:flex; align-items:center; gap:8px; font-size:13.5px; color:var(--text-dim); cursor:pointer; }
label.checkbox input{ width:16px; height:16px; }

.btn{ display:inline-flex; align-items:center; gap:8px; text-decoration:none; font-size:14px; font-weight:600; border-radius:6px; padding:10px 18px; border:1px solid transparent; cursor:pointer; font-family:inherit; }
.btn-primary{ background:var(--accent); color:#0a0c0f; }
.btn-ghost{ background:transparent; border-color:var(--border); color:var(--text); }
.btn-danger{ background:transparent; border-color:var(--danger); color:var(--danger); }
.btn-sm{ padding:6px 12px; font-size:12.5px; }
.btn:disabled{ opacity:.6; cursor:not-allowed; }

.note{ border-radius:6px; padding:12px 14px; font-size:13.5px; margin-bottom:18px; border:1px solid; }
.note.ok{ background:var(--ok-soft); border-color:var(--ok); color:var(--text); }
.note.warn{ background:var(--danger-soft); border-color:var(--danger); color:var(--text); }
.note.info{ background:var(--accent-2-soft); border-color:var(--accent-2); color:var(--text); }

.stat-row{ display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin-bottom:28px; }
.stat{ background:var(--surface); border:1px solid var(--border); border-radius:6px; padding:16px 18px; }
.stat .n{ font-family:"IBM Plex Mono",monospace; font-size:24px; font-weight:600; color:var(--accent); }
.stat .l{ font-size:12px; color:var(--text-dim); margin-top:4px; }

.section-title{ font-size:13px; font-family:"IBM Plex Mono",monospace; color:var(--text-faint); letter-spacing:.06em; margin:36px 0 12px; text-transform:uppercase; }
.section-title:first-child{ margin-top:0; }

.card-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:14px; }
.mini-card{ background:var(--surface); border:1px solid var(--border); border-radius:6px; padding:16px; }
.mini-card h4{ font-size:14.5px; margin-bottom:6px; }
.mini-card p{ font-size:12.5px; color:var(--text-dim); margin-bottom:12px; min-height:32px; }
.mini-card .row{ display:flex; gap:8px; align-items:center; justify-content:space-between; }
.mini-card .tag{ font-family:"IBM Plex Mono",monospace; font-size:10.5px; color:var(--accent-2); }

table{ width:100%; border-collapse:collapse; font-size:13.5px; }
th{ text-align:right; font-family:"IBM Plex Mono",monospace; font-size:11px; color:var(--text-faint); font-weight:500; padding:10px 12px; border-bottom:1px solid var(--border); white-space:nowrap; }
td{ padding:12px; border-bottom:1px solid var(--border-soft); vertical-align:top; }
tr:last-child td{ border-bottom:none; }
.table-wrap{ overflow-x:auto; border:1px solid var(--border); border-radius:6px; }
.table-wrap table{ min-width:640px; }

.badge{ display:inline-block; font-family:"IBM Plex Mono",monospace; font-size:10.5px; padding:3px 9px; border-radius:999px; border:1px solid; }
.badge.new{ color:var(--accent-2); border-color:var(--accent-2); background:var(--accent-2-soft); }
.badge.read{ color:var(--text-dim); border-color:var(--border); background:var(--surface-2); }
.badge.replied{ color:var(--ok); border-color:var(--ok); background:var(--ok-soft); }
.badge.archived{ color:var(--text-faint); border-color:var(--border-soft); background:transparent; }

.status-form{ display:inline-flex; gap:6px; align-items:center; }
.status-form select{ padding:5px 8px; font-size:12px; width:auto; }
.status-form .btn-sm{ padding:5px 10px; }

.msg-cell{ max-width:280px; white-space:pre-wrap; word-break:break-word; color:var(--text-dim); font-size:13px; }

.divider{ height:1px; background:var(--border-soft); margin:36px 0; }

pre.build-log{ background:var(--surface-2); border:1px solid var(--border); border-radius:8px; padding:14px; font-family:"IBM Plex Mono",monospace; font-size:12px; color:var(--text-dim); max-height:340px; overflow:auto; direction:ltr; text-align:left; white-space:pre-wrap; }

.top-actions{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; justify-content:space-between; margin-bottom:20px; }
