/* نظام التصميم نفسه في تطبيق الهاتف (app/lib/src/theme.dart): لوحة فاتحة
   واحدة، خط Tajawal، بطاقات، أزرار وحقول بيضاوية، وجدول بخطوط. */
@font-face { font-family: Tajawal; src: url(Tajawal-Regular.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: Tajawal; src: url(Tajawal-Bold.ttf); font-weight: 700; font-display: swap; }

:root {
  --bg: #e2e9f5;
  --card: #edeff4;
  --paper: #f7f8fa;
  --fill: #d3daea;
  --tile: #dce1ea;
  --sheet: #dae2f1;
  --primary: #3a5795;
  --ink: #14161a;
  --muted: #5e6573;
  --line: #c4cbd9;
  --table-head: #d3dcee;
  --table-row: #e9eef7;
  --success: #4caf50;
  --success-tile: #dcebdf;
  --danger: #e94f4f;
  --danger-tile: #f3dadb;
  --shadow: 0 2px 3px rgba(96, 106, 128, .2);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 Tajawal, "Segoe UI", Tahoma, system-ui, sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.2rem; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

header.top {
  max-width: 1000px;
  margin: 0 auto;
  padding: 18px 20px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
header.top .grow { flex: 1; min-width: 120px; }
nav.tabs {
  max-width: 960px;
  margin: 6px auto 0;
  display: flex;
  gap: 4px;
  padding: 10px 14px 0;
  background: var(--fill);
  border-radius: 20px;
  overflow-x: auto;
}
nav.tabs button {
  background: none;
  box-shadow: none;
  border-radius: 0;
  color: var(--ink);
  padding: 8px 16px 12px;
  white-space: nowrap;
  font-size: 1.05rem;
  border-bottom: 4px solid transparent;
}
nav.tabs button[aria-selected="true"] { color: var(--primary); border-color: var(--primary); }
main { max-width: 1000px; margin: 0 auto; padding: 20px 20px 64px; }

button, input, select { font: inherit; color: inherit; }
/* الزر الافتراضي هو زر البطاقة الهادئ («التفاصيل»). */
button {
  cursor: pointer;
  border: 0;
  background: var(--tile);
  color: var(--primary);
  font-weight: 700;
  border-radius: 22px;
  padding: 12px 22px;
}
button:hover { filter: brightness(.97); }
button:disabled { opacity: .5; cursor: default; filter: none; }
button.primary { background: var(--primary); color: #fff; border-radius: 999px; box-shadow: var(--shadow); }
button.danger { background: var(--paper); color: var(--danger); border: 1.6px solid var(--danger); border-radius: 999px; }
button.primary.danger { background: var(--danger); color: #fff; border: 0; }
button.small { padding: 8px 16px; font-size: .95rem; border-radius: 16px; }
button.small.danger { border-radius: 16px; }
button.link { background: none; padding: 0; border-radius: 4px; color: var(--primary); text-align: start; }
button.link:hover { text-decoration: underline; filter: none; }
input, select {
  width: 100%;
  padding: 14px 20px;
  border: 1.5px solid transparent;
  border-radius: 24px;
  background: var(--fill);
}
input::placeholder { color: var(--muted); }
input:focus-visible, select:focus-visible { outline: 0; border-color: var(--primary); }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }
label { display: block; font-size: .95rem; color: var(--muted); margin: 0 12px 4px; }
.field { margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.row > * { flex: 1; min-width: 150px; }
.row > .fit { flex: 0 0 auto; min-width: 0; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.checks label {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-direction: row-reverse;
  margin: 0;
  padding: 14px 20px;
  background: var(--fill);
  border-radius: 14px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}
[hidden] { display: none !important; }

.card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card > h2 { margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--fill); border-radius: 24px; padding: 22px 14px; text-align: center; }
.stat .muted { color: var(--ink); font-weight: 700; }
.stat .v { font-size: 1.8rem; font-weight: 700; color: var(--primary); margin-top: 10px; }
.stat.bad .v { color: var(--danger); }
.bar { height: 14px; background: var(--tile); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: center; padding: 12px 10px; border: 1px solid var(--line); vertical-align: middle; }
th { background: var(--table-head); font-weight: 700; white-space: nowrap; }
td { background: var(--table-row); }
td.actions { white-space: nowrap; }
td.actions button { margin-inline: 3px; }
.chip { display: inline-block; background: var(--tile); color: var(--primary); font-weight: 700; border-radius: 12px; padding: 2px 12px; font-size: .9rem; margin: 2px; }
.chip.off { background: var(--danger-tile); color: var(--danger); }

.notice { border-radius: 14px; padding: 14px 18px; margin-bottom: 16px; background: var(--fill); }
.notice.error { background: var(--danger-tile); color: var(--danger); }

.login { max-width: 420px; margin: 12vh auto 0; padding: 0 20px; }
.login h1 { text-align: center; margin-bottom: 4px; font-size: 1.7rem; font-weight: 400; }
.login p { text-align: center; margin: 0 0 28px; }
.login button { width: 100%; padding: 16px; font-size: 1.15rem; margin-top: 8px; }

/* الحوار بهيئة الحوار السفلي في التطبيق: ترويسة بخط فاصل وأزرار بعرض كامل. */
dialog {
  border: 0;
  border-radius: 28px;
  background: var(--sheet);
  color: var(--ink);
  padding: 0 20px 20px;
  width: min(540px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(60, 80, 130, .35); }
dialog h2 { text-align: center; padding: 20px 0 16px; margin: 0 -20px 18px; border-bottom: 1px solid var(--line); }
dialog .buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
dialog .buttons button { padding: 16px; font-size: 1.1rem; border-radius: 999px; }
dialog .buttons button:not(.primary) { background: var(--paper); border: 1.6px solid var(--primary); }

#toast {
  position: fixed;
  inset-inline: 0;
  bottom: 24px;
  margin: 0 auto;
  width: fit-content;
  max-width: calc(100vw - 32px);
  background: var(--success);
  color: #fff;
  font-weight: 700;
  padding: 14px 26px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
#toast.show { opacity: 1; }
