:root {
  font-family: "Vazirmatn", "Noto Sans Arabic", Tahoma, system-ui, sans-serif;
  color: #202921; background: #f4f5f0; font-size: 14px; line-height: 1.65;
  --ink: #202921; --muted: #59655c; --rule: #dce2d9; --paper: #fff;
  --accent: #14634b; --lime: #d9f879; --night: #182921; --danger: #a82e38;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: progress; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; border: 1px solid var(--rule); border-radius: 7px; background: var(--paper); color: var(--ink); padding: .42rem .8rem; text-decoration: none; white-space: nowrap; }
button:hover, .button:hover { background: #f1f5ee; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #3b8c60; outline-offset: 2px; }
button.primary, .button.primary { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 700; }
button.primary:hover, .button.primary:hover { background: #0c523e; }
button.quiet { background: transparent; border-color: transparent; }
button.danger { color: var(--danger); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -.015em; font-size: 16px; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--lime); color: var(--night); font: 700 23px system-ui; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(26px, 3vw, 38px); line-height: 1.3; letter-spacing: -.04em; }
h2 { font-size: 17px; line-height: 1.5; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); min-height: 1em; }
.app { min-height: 100vh; display: grid; grid-template-columns: 216px minmax(0, 1fr); }
.sidebar { background: var(--night); color: #eef6eb; padding: 29px 21px; display: flex; flex-direction: column; gap: 52px; position: sticky; top: 0; height: 100vh; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav button { justify-content: flex-start; gap: 12px; background: transparent; border: 1px solid transparent; color: #d1ded2; padding: .55rem .7rem; }
.sidebar nav button:hover { background: #24392c; }
.sidebar nav button.selected { color: var(--lime); background: #2c4233; border-color: #3c5140; }
.sidebar nav span { width: 20px; text-align: center; font: 600 18px system-ui; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid #3d5141; padding-top: 16px; color: #c7d4c9; display: grid; gap: 6px; font-size: 12px; }
.sidebar-bottom bdi { color: #eff5ed; font: 13px ui-monospace, monospace; }
.workspace { min-width: 0; max-width: 1520px; margin: 0 auto; width: 100%; }
.topbar { padding: 19px clamp(18px, 4vw, 48px); display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--rule); }
.top-actions, .toolbar, .actions, .dialog-foot { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.health, .tag { display: inline-flex; gap: 6px; align-items: center; border-radius: 5px; padding: 2px 8px; background: #e8eae3; color: var(--muted); white-space: nowrap; font-size: 12px; }
.health i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.health.ok, .tag.ok { background: #e2f1e4; color: #226141; }
.health.bad, .tag.bad { background: #f6e5e1; color: #922d37; }
.tag.wait { background: #f4efda; color: #735a1e; }
#screen { padding: 32px clamp(18px, 4vw, 48px) 56px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 22px; }
.page-head p { margin-top: 8px; }
.strip { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; margin-bottom: 21px; }
.metric { display: grid; align-content: center; gap: 7px; padding: 17px 20px; min-height: 106px; border-inline-start: 1px solid var(--rule); }
.metric:first-child { border: 0; }
.metric strong { font-size: clamp(19px, 2.7vw, 30px); line-height: 1.1; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; margin-bottom: 21px; }
.section-head { padding: 17px 20px 11px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.chart { padding: 0 20px 12px; }
.chart svg { width: 100%; max-height: 210px; display: block; overflow: visible; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.legend span::before { display: inline-block; content: ""; width: 9px; height: 9px; border-radius: 2px; margin-inline-end: 5px; background: #55a889; }
.legend span:last-child::before { background: #c5e579; }
.table-wrap { overflow-x: auto; }
table { width: 100%; text-align: start; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 15px; border-top: 1px solid var(--rule); text-align: start; }
th { color: var(--muted); background: #f7f9f5; font-size: 12px; font-weight: 600; }
td:first-child, th:first-child { padding-inline-start: 20px; }
td:last-child, th:last-child { padding-inline-end: 20px; }
td .sub { display: block; color: var(--muted); font-size: 11px; }
td button, td .button { min-height: 32px; font-size: 12px; }
.empty { color: var(--muted); padding: 21px 20px; }
input:not([type=checkbox]), select { min-height: 42px; border: 1px solid var(--rule); border-radius: 7px; background: #fff; color: var(--ink); padding: 7px 10px; width: 100%; }
.toolbar { padding: 0 20px 15px; }
.toolbar input { max-width: 280px; }
.toolbar select { width: auto; }
label { display: grid; gap: 6px; }
label.check { display: flex; align-items: center; gap: 8px; }
input[type=checkbox] { accent-color: var(--accent); }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate-card { max-width: 410px; width: 100%; padding: 30px; background: var(--paper); border: 1px solid var(--rule); border-top: 4px solid var(--accent); border-radius: 12px; }
.gate-card h1 { font-size: 25px; margin-top: 26px; }
.gate-card p { margin: 10px 0; }
.gate-card form { display: grid; gap: 12px; }
dialog { width: min(570px, calc(100vw - 28px)); max-height: calc(100dvh - 30px); border: 1px solid var(--rule); border-radius: 12px; padding: 24px; background: var(--paper); color: var(--ink); }
dialog::backdrop { background: #11271980; }
dialog form, #detail-content { display: grid; gap: 16px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
.form-grid, .detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detail-grid > div { display: grid; padding: 10px; background: #f4f6f1; border-radius: 6px; }
.toast { position: fixed; bottom: 16px; inset-inline-start: 16px; max-width: calc(100vw - 32px); background: var(--night); color: white; z-index: 5; border-radius: 8px; padding: 10px 15px; }
@media (max-width: 860px) {
  .app { grid-template-columns: 150px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .metric { padding-inline: 12px; }
}
@media (max-width: 620px) {
  .app { display: block; }
  .sidebar { position: static; height: auto; padding: 12px 15px 8px; gap: 11px; }
  .sidebar nav { display: flex; gap: 4px; }
  .sidebar nav button { padding-inline: 9px; min-height: 35px; }
  .sidebar-bottom { display: none; }
  .topbar { padding-block: 10px; }
  #screen { padding-top: 22px; }
  .strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .metric { min-height: 76px; }
  .metric:nth-child(3) { border-inline-start: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .table-wrap { scrollbar-width: thin; }
  dialog { padding: 16px; }
}
