:root {
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  color: #171717;
  background: #fafafa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #171717;
  --muted: #777;
  --soft: #999;
  --line: #e8e8e8;
  --panel: #fff;
  --wash: #f6f6f6;
  --green: #198754;
  --green-bg: #edf8f1;
  --red: #c33d3d;
  --red-bg: #fff0ef;
  --shadow: 0 16px 50px rgba(0, 0, 0, .1);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
a { color: inherit; }
code, pre, .mono { font-family: "IBM Plex Mono", ui-monospace, monospace; direction: ltr; }
.boot { display: flex; min-height: 100vh; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.spinner { width: 16px; height: 16px; border: 2px solid #ddd; border-top-color: #171717; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-wrap { display: grid; min-height: 100vh; grid-template-columns: minmax(380px, 1fr) minmax(420px, 1fr); background: #fff; }
.auth-aside { display: flex; flex-direction: column; justify-content: space-between; padding: 38px 44px; color: #f9f9f9; background: #111; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 700; font-size: 18px; letter-spacing: -.3px; }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; color: #111; background: #fff; font-family: "IBM Plex Mono", monospace; font-size: 14px; }
.aside-content { max-width: 470px; margin: auto 0; }
.aside-content h1 { margin: 0 0 18px; font-size: clamp(32px, 4vw, 54px); letter-spacing: -1.5px; line-height: 1.25; }
.aside-content p { max-width: 410px; margin: 0; color: #b6b6b6; font-size: 16px; line-height: 1.9; }
.aside-code { margin-top: 40px; padding: 18px; border: 1px solid #333; border-radius: 12px; color: #d5d5d5; background: #171717; direction: ltr; text-align: left; font-size: 12px; line-height: 1.9; overflow: auto; }
.aside-foot { color: #888; font-size: 12px; }
.auth-main { display: grid; place-items: center; padding: 32px; }
.auth-card { width: min(420px, 100%); }
.auth-card h2 { margin: 0 0 8px; font-size: 27px; letter-spacing: -.5px; }
.auth-sub { margin: 0 0 28px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.auth-switch { display: flex; margin-bottom: 22px; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: #f8f8f8; }
.auth-switch button { flex: 1; padding: 9px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; }
.auth-switch button.active { color: var(--ink); background: white; box-shadow: 0 1px 3px #00000012; }
.field { display: grid; gap: 7px; margin-bottom: 16px; text-align: right; }
.field label { color: #383838; font-size: 13px; font-weight: 600; }
.field input, .field textarea, .field select { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid #dedede; border-radius: 7px; outline: none; color: var(--ink); background: #fff; direction: ltr; text-align: left; font-size: 14px; transition: border .15s, box-shadow .15s; }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #888; box-shadow: 0 0 0 3px #1111110b; }
.help { color: var(--soft); font-size: 12px; line-height: 1.7; }
.btn { display: inline-flex; min-height: 37px; align-items: center; justify-content: center; gap: 8px; padding: 8px 13px; border: 1px solid transparent; border-radius: 7px; font-size: 13px; font-weight: 600; transition: background .15s, border .15s; }
.btn-primary { color: #fff; background: #171717; }
.btn-primary:hover { background: #303030; }
.btn-secondary { border-color: var(--line); color: #333; background: #fff; }
.btn-secondary:hover { background: #f7f7f7; }
.btn-danger { border-color: #f1dddd; color: var(--red); background: #fff; }
.btn-small { min-height: 29px; padding: 5px 9px; font-size: 12px; }
.full { width: 100%; }
.auth-note { margin-top: 17px; color: #8a8a8a; font-size: 11px; line-height: 1.8; }
.text-button { display: block; margin: 14px auto 0; padding: 4px; border: 0; color: #666; background: transparent; font-size: 12px; }
.text-button:hover { color: #111; text-decoration: underline; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 244px 1fr; }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; padding: 20px 13px 14px; border-left: 1px solid var(--line); background: #fff; }
.sidebar .brand { padding: 0 10px 23px; }
.sidebar .brand-mark { border: 1px solid #e5e5e5; }
.workspace-label { padding: 0 11px 8px; color: #929292; font-size: 11px; font-weight: 600; }
.workspace-switch { display: flex; align-items: center; gap: 9px; margin: 0 4px 19px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 12px; }
.workspace-avatar { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 7px; color: white; background: #333; font-size: 11px; }
.workspace-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-chevron { color: #999; }
.nav-group { display: grid; gap: 3px; }
.nav-item { display: flex; height: 36px; align-items: center; gap: 11px; padding: 0 11px; border: 0; border-radius: 7px; color: #666; background: transparent; text-align: right; font-size: 13px; }
.nav-item:hover { color: #111; background: #f7f7f7; }
.nav-item.active { color: #171717; background: #f1f1f1; font-weight: 600; }
.nav-icon { width: 17px; color: #777; text-align: center; font-size: 15px; }
.sidebar-spacer { flex: 1; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 5px; padding-top: 14px; border-top: 1px solid #eee; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 10px; }
.user-dot { display: grid; width: 28px; height: 28px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #fff; background: #4f5d51; font-size: 12px; }
.user-details { min-width: 0; flex: 1; }
.user-email { overflow: hidden; color: #333; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.user-role { margin-top: 2px; color: #999; font-size: 10px; }
.main-area { min-width: 0; }
.topbar { position: sticky; z-index: 5; top: 0; display: flex; height: 58px; align-items: center; justify-content: space-between; padding: 0 34px; border-bottom: 1px solid var(--line); background: #ffffffed; backdrop-filter: blur(12px); }
.crumb { color: #777; font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.service-status { display: inline-flex; align-items: center; gap: 7px; color: #666; font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #24a360; }
.page { width: min(1160px, 100%); margin: 0 auto; padding: 34px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
.eyebrow { margin-bottom: 7px; color: #888; font-size: 11px; }
.page-title { margin: 0; font-size: 23px; letter-spacing: -.6px; }
.page-description { margin: 7px 0 0; color: #777; font-size: 13px; line-height: 1.8; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.metric { min-height: 107px; padding: 17px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.metric-label { color: #777; font-size: 12px; }
.metric-value { margin-top: 14px; font-family: "IBM Plex Mono", monospace; font-size: 26px; letter-spacing: -.8px; }
.metric-note { margin-top: 2px; color: #aaa; font-size: 10px; }
.card { border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid #eee; }
.card-title { margin: 0; font-size: 13px; font-weight: 600; }
.card-subtitle { margin-top: 4px; color: #999; font-size: 11px; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; text-align: right; }
th { padding: 11px 17px; color: #999; background: #fcfcfc; font-size: 10px; font-weight: 500; white-space: nowrap; }
td { padding: 13px 17px; border-top: 1px solid #f0f0f0; color: #444; white-space: nowrap; }
tr:hover td { background: #fdfdfd; }
.truncate { display: inline-block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 20px; font-size: 10px; }
.badge::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ""; }
.badge-sent, .badge-verified { color: var(--green); background: var(--green-bg); }
.badge-failed, .badge-unverified { color: var(--red); background: var(--red-bg); }
.badge-sending { color: #96630a; background: #fff8e9; }
.empty { display: grid; min-height: 170px; place-items: center; padding: 26px; color: #888; text-align: center; font-size: 12px; line-height: 1.9; }
.empty strong { display: block; margin-bottom: 5px; color: #333; font-size: 13px; }
.panel-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.callout { padding: 15px 17px; border: 1px solid #ece7d9; border-radius: 9px; background: #fffcf4; }
.callout h3 { margin: 0 0 7px; font-size: 12px; }
.callout p { margin: 0; color: #74706a; font-size: 11px; line-height: 1.9; }
.callout code { display: inline-block; margin: 7px 0; padding: 5px 7px; border-radius: 5px; color: #49453e; background: #f3efe4; font-size: 10px; overflow-wrap: anywhere; }
.codebox { margin: 0; padding: 15px; border: 1px solid #292929; border-radius: 8px; color: #eee; background: #171717; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; line-height: 1.8; }
.code-label { margin: 18px 0 8px; color: #555; font-size: 12px; font-weight: 600; }
.inline-code { direction: ltr; text-align: left; }
.notice { padding: 12px 14px; border-radius: 8px; color: #6d5c2c; background: #fff8e9; font-size: 11px; line-height: 1.8; }
.key-secret { margin-top: 12px; padding: 12px; border: 1px solid #e7e4dc; border-radius: 8px; background: #faf9f5; }
.key-secret code { display: block; margin: 8px 0; overflow-wrap: anywhere; font-size: 12px; }
.domain-dns { display: grid; grid-template-columns: 50px 1fr; gap: 5px 8px; margin-top: 10px; color: #858078; font-size: 10px; }
.domain-dns code { color: #3c3a36; overflow-wrap: anywhere; }
.template-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.template-card { padding: 15px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.template-card h3 { margin: 0 0 7px; font-size: 13px; }
.template-card p { margin: 0 0 13px; color: #777; font-size: 11px; }
.template-actions { display: flex; gap: 7px; }
.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 18px; background: #0007; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: 21px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head p { margin: 5px 0 0; color: #888; font-size: 11px; line-height: 1.7; }
.modal-close { width: 30px; height: 30px; border: 0; border-radius: 6px; color: #777; background: transparent; font-size: 18px; }
.modal-close:hover { background: #f5f5f5; }
.modal-foot { display: flex; justify-content: flex-start; gap: 8px; margin-top: 20px; }
#toast-region { position: fixed; z-index: 40; left: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { max-width: min(420px, calc(100vw - 40px)); padding: 11px 15px; border: 1px solid #ddd; border-radius: 8px; color: #222; background: #fff; box-shadow: 0 8px 30px #00000012; font-size: 12px; animation: show .18s ease-out; }
.toast.error { border-color: #f0d0ce; color: #993c38; }
@keyframes show { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.mobile-menu { display: none; }

@media (max-width: 1000px) {
  .auth-wrap { grid-template-columns: minmax(320px, .9fr) minmax(390px, 1.1fr); }
  .auth-aside { padding: 28px; }
  .app-shell { grid-template-columns: 215px 1fr; }
  .page { padding: 25px; }
  .topbar { padding: 0 25px; }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { min-height: 230px; padding: 20px; }
  .auth-aside .aside-content { margin: 35px 0 15px; }
  .aside-content h1 { font-size: 30px; }
  .aside-content p, .aside-code, .aside-foot { display: none; }
  .auth-main { padding: 28px 20px 45px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 10; right: 0; width: 260px; transform: translateX(105%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-flex; }
  .topbar { height: 54px; padding: 0 15px; }
  .page { padding: 22px 15px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .metric { min-height: 94px; padding: 13px; }
  .metric-value { font-size: 23px; }
  .template-list { grid-template-columns: 1fr; }
  td, th { padding-right: 12px; padding-left: 12px; }
}
