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

:root {
  --bg: #fefcf9;
  --bg-100: #f8f5f1;
  --line: #efece7;
  --line-strong: #e1ded7;
  --ink: #201e19;
  --muted: #6e6b66;
  --faint: #8b8984;
  --sidebar: #1b1914;
  --sidebar-deep: #040402;
  --cream: #f6f1e8;
  --accent: #a76924;
  --accent-soft: #ffe5c8;
  --accent-text: #754513;
  --success: #34814e;
  --success-soft: #e5f4ea;
  --warning: #bf8f34;
  --warning-soft: #fff3d8;
  --danger: #ba3e38;
  --danger-soft: #fdecec;
  --info: #497b81;
  --shadow: 0 18px 50px rgba(27, 25, 20, 0.08);
  --font: "IBM Plex Sans Arabic", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif;
  --heading: "Alexandria", "IBM Plex Sans Arabic", "Noto Naskh Arabic", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--heading); font-weight: 650; letter-spacing: 0; margin: 0; }
img { max-width: 100%; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(circle at top, rgba(167, 105, 36, 0.08), transparent 36%),
    var(--bg);
}
.login-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
  display: grid;
  gap: 14px;
}
.logo { width: 118px; }
.login-card h1 { font-size: 30px; }
.lead, .muted { color: var(--muted); line-height: 1.7; margin: 0; }
.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #c4a574; }
button, .button {
  border: 0;
  border-radius: 10px;
  background: var(--sidebar);
  color: var(--cream);
  padding: 11px 16px;
  font-weight: 600;
}
.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.danger { background: var(--danger); color: #fff; }
.form-error { color: var(--danger); margin: 0; font-size: 13px; }

.app { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar {
  background: var(--sidebar);
  color: var(--cream);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand img { width: 86px; }
.brand span { color: var(--accent-soft); font-size: 13px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar button {
  text-align: start;
  background: transparent;
  color: rgba(246, 241, 232, 0.78);
  border-radius: 10px;
  padding: 11px 12px;
}
.sidebar button.active,
.sidebar button:hover { background: rgba(255, 255, 255, 0.08); color: var(--accent-soft); }
.main { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 22px 28px 8px;
}
.topbar h2 { font-size: 28px; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 10px; color: var(--muted); }
#view { padding: 12px 28px 40px; display: grid; gap: 16px; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.card, .panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.card span, .panel .label { color: var(--faint); font-size: 13px; }
.card strong, .panel > strong { display: block; margin-top: 8px; font-family: var(--heading); font-size: 28px; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.row-actions, .chips, .checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border-radius: 999px;
  background: var(--bg-100);
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: 12px;
}
.chip.on { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.status { border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.status.active, .status.paid { background: var(--success-soft); color: var(--success); }
.status.trial, .status.approved { background: #e7f3f4; color: var(--info); }
.status.past_due, .status.requested { background: var(--warning-soft); color: #8a6418; }
.status.cancelled, .status.rejected, .status.suspended, .status.hidden { background: var(--danger-soft); color: var(--danger); }
.status.disabled { background: var(--bg-100); color: var(--muted); }

.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.plan h3 { font-size: 22px; }
.price { font-family: var(--heading); font-size: 26px; margin: 8px 0; }
.plan p { color: var(--muted); line-height: 1.7; }
.services { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.service {
  background: var(--sidebar);
  color: var(--cream);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}

table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: start; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--faint); font-size: 12px; font-weight: 600; background: var(--bg-100); }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fffaf3; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: end; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.meter { height: 8px; background: var(--bg-100); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter span { display: block; height: 100%; background: var(--accent); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(27, 25, 20, 0.46);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}
.dialog {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  display: grid;
  gap: 12px;
}
.dialog header, .dialog footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dialog footer { justify-content: flex-end; }
.icon { width: 36px; height: 36px; padding: 0; background: var(--bg-100); color: var(--ink); }
.checks label { display: flex; align-items: center; gap: 6px; color: var(--ink); }
.checks input { width: auto; }
.toast {
  position: fixed;
  bottom: 18px;
  left: 18px;
  background: var(--sidebar);
  color: var(--cream);
  border-radius: 12px;
  padding: 12px 14px;
  z-index: 30;
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }
  .sidebar nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cards, .plans { grid-template-columns: 1fr; }
  .topbar, #view { padding-inline: 16px; }
  table { display: block; overflow-x: auto; }
}
