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

:root{
  --bg:#eef1f4;
  --bg-2:#e6eaee;
  --surface:#ffffff;
  --surface-2:#fbfcfd;
  --border:#dde2e7;
  --border-lt:#c7ced5;
  --text:#1c2126;
  --text-dim:#5b6672;
  --text-faint:#8b95a0;
  --white:#ffffff;
  --heading:#141a1f;
  --safety:#2f6fd6;
  --safety-dark:#1154ab;
  --safety-dim:#e7eefb;
  --ok:#1f9d5c;
  --ok-dim:#e5f6ec;
  --admin:#6f5cd6;
  --admin-dark:#5847b8;
  --admin-dim:#efecfc;
  --danger:#d1483a;
  --danger-dim:#fbeae8;
  --shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 14px 30px -16px rgba(15,23,42,.14);
  --shadow-sm: 0 1px 0 rgba(255,255,255,.7) inset, 0 6px 16px -10px rgba(15,23,42,.10);
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  font-family:'Vazirmatn', Tahoma, sans-serif;
  background:
    radial-gradient(900px 500px at 90% -10%, rgba(47,111,214,.08) 0%, transparent 60%),
    var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  min-height:100vh;
}
body.theme-admin{
  background:
    radial-gradient(900px 500px at 90% -10%, rgba(143,124,240,.07) 0%, transparent 60%),
    var(--bg);
}
.mono{ font-family:'IBM Plex Mono','Vazirmatn',monospace; direction:ltr; unicode-bidi:isolate; }
a{ color:inherit; }
button{ font-family:inherit; }

/* ===== steel plate header ===== */
.plate-header{
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,.02) 0 2px, transparent 2px 6px),
    linear-gradient(160deg, #14181c 0%, #0c0e10 100%);
  color:var(--text);
  position:relative;
  overflow:hidden;
  border-bottom:1px solid var(--border);
}
.plate-header::after{
  content:"";
  position:absolute; inset:auto 0 0 0; height:3px;
  background:repeating-linear-gradient(-45deg, var(--safety) 0 10px, #14181c 10px 20px);
  opacity:.9;
}
.theme-admin .plate-header::after{
  background:repeating-linear-gradient(-45deg, var(--admin) 0 10px, #14181c 10px 20px);
}
.plate-inner{
  max-width:1180px; margin:0 auto; padding:22px 24px;
  display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap;
}
.brand{ display:flex; align-items:center; gap:12px; }
.brand-mark{
  width:42px; height:42px; border-radius:6px;
  background:linear-gradient(160deg, var(--safety) 0%, var(--safety-dark) 100%);
  display:flex; align-items:center; justify-content:center;
  color:#ffffff; font-weight:800; font-size:17px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), 0 6px 16px -6px rgba(17,84,171,.6);
  flex-shrink:0;
}
.theme-admin .brand-mark{
  background:linear-gradient(160deg, var(--admin) 0%, var(--admin-dark) 100%);
  color:#100c26;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), 0 6px 16px -6px rgba(143,124,240,.6);
}
.brand-logo{
  width:60px; height:60px; border-radius:50%;
  background:transparent;
  display:flex; align-items:center; justify-content:center;
  padding:0;
  flex-shrink:0;
  overflow:hidden;
}
.brand-logo img{ width:100%; height:100%; object-fit:contain; }
.brand-logo.lg{ width:60px; height:60px; }
.brand-logo-cluster{ display:flex; align-items:center; gap:10px; }
.brand-text .t1{ font-weight:800; font-size:16px; letter-spacing:.2px; color:var(--white); }
.brand-text .t1.xl{ font-size:21px; }
.brand-text .t2{ font-size:11.5px; color:var(--text-dim); margin-top:2px; letter-spacing:.3px; }
.holding-subbar{ border-top:1px solid var(--border); background:rgba(47,111,214,.07); }
.holding-subbar-inner{
  max-width:1180px; margin:0 auto; padding:10px 24px;
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
}
.hs-label{ font-size:11.5px; color:var(--text-dim); font-weight:600; }
.brand-chip{
  display:inline-flex; align-items:center; gap:6px;
  font-size:12px; font-weight:700; color:var(--safety);
  background:var(--safety-dim); border:1px solid rgba(47,111,214,.4);
  border-radius:20px; padding:4px 15px; letter-spacing:.2px;
}
.brand-chip:has(img){ padding:3px 15px 3px 4px; }
.brand-chip img{ width:18px; height:18px; border-radius:50%; background:#fff; object-fit:contain; padding:1px; }
.header-tag{
  font-size:11px; font-weight:700; color:var(--safety);
  border:1px solid rgba(47,111,214,.4); border-radius:20px;
  background:rgba(47,111,214,.1);
  padding:6px 14px; letter-spacing:.3px;
}
.theme-admin .header-tag{
  color:var(--admin); border-color:rgba(143,124,240,.4); background:rgba(143,124,240,.1);
}
.top-actions{ display:flex; align-items:center; gap:14px; }
.logout-link{ font-size:12.5px; color:var(--text-dim); text-decoration:none; cursor:pointer; }
.logout-link:hover{ color:var(--white); }

.shell{ max-width:1080px; margin:0 auto; padding:34px 20px 90px; }
.shell.wide{ max-width:1180px; }

.eyebrow{
  display:inline-flex; align-items:center; gap:8px;
  font-size:11.5px; color:var(--safety); font-weight:700;
  letter-spacing:.4px; margin-bottom:10px; text-transform:uppercase;
}
.eyebrow::before{ content:""; width:18px; height:2px; background:var(--safety); }
.theme-admin .eyebrow{ color:var(--admin); }
.theme-admin .eyebrow::before{ background:var(--admin); }
h1{ font-size:24px; margin:0 0 8px; font-weight:800; color:var(--heading); }
.sub{ color:var(--text-dim); font-size:13.5px; margin:0 0 30px; line-height:1.9; max-width:680px; }

/* ===== unit / product picker cards ===== */
.unit-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-bottom:34px; }
@media (max-width:900px){ .unit-grid{ grid-template-columns:repeat(2,1fr); } }
@media (max-width:560px){ .unit-grid{ grid-template-columns:1fr; } }
.unit-card{
  position:relative; cursor:pointer; text-align:right;
  background:linear-gradient(175deg, var(--surface-2) 0%, var(--surface) 100%);
  border:1px solid var(--border); border-radius:12px;
  padding:22px 18px 20px; overflow:hidden;
  transition: border-color .15s, transform .12s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.unit-card::before, .unit-card::after{
  content:""; position:absolute; width:5px; height:5px; border-radius:50%;
  background:var(--border-lt); box-shadow: inset 0 1px 1px rgba(0,0,0,.6);
}
.unit-card::before{ top:9px; right:9px; }
.unit-card::after{ top:9px; left:9px; }
.unit-card:hover{ transform:translateY(-2px); border-color:var(--border-lt); }
.unit-card.selected{ border-color:var(--safety); box-shadow: var(--shadow), 0 0 0 1px rgba(47,111,214,.35); }
.unit-card.selected::before, .unit-card.selected::after{ background:var(--safety); box-shadow:0 0 6px rgba(17,84,171,.7); }
.unit-tab{
  position:absolute; top:0; left:0; font-size:9.5px; font-weight:800; letter-spacing:1px;
  padding:4px 10px 4px 8px; border-radius:0 0 10px 0; color:#ffffff;
  background:repeating-linear-gradient(-45deg, var(--safety) 0 6px, #1154ab 6px 12px);
  opacity:0; transform:translateY(-4px); transition:.15s;
}
.unit-card.selected .unit-tab{ opacity:1; transform:translateY(0); }
.unit-icon{
  width:36px; height:36px; border-radius:8px; background:var(--bg-2);
  border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center; margin-bottom:14px; color:var(--safety);
}
.unit-icon svg{ width:19px; height:19px; }
.unit-name{ font-size:13.5px; font-weight:700; line-height:1.7; color:var(--text); }
.unit-radio{ display:none; }

/* ===== segmented control ===== */
.seg{
  display:inline-flex; background:var(--bg-2); border:1px solid var(--border);
  border-radius:10px; padding:3px; margin-bottom:26px; flex-wrap:wrap;
}
.seg button{
  appearance:none; border:none; cursor:pointer; font-family:inherit;
  font-size:13px; font-weight:700; padding:9px 22px; border-radius:8px;
  background:transparent; color:var(--text-dim); transition:.15s;
}
.seg button.on{ background:var(--safety); color:#ffffff; box-shadow:var(--shadow-sm); }
.theme-admin .seg button.on{ background:var(--admin); color:#100c26; }

.section{ display:none; }
.section.on{ display:block; }

/* ===== form fields ===== */
.grid{ display:grid; grid-template-columns:1fr 1fr; gap:18px 20px; }
@media (max-width:560px){ .grid{ grid-template-columns:1fr; } }
.field{ display:flex; flex-direction:column; gap:7px; }
.field.full{ grid-column:1/-1; }
.field label{ font-size:12.5px; font-weight:700; color:var(--text); }
.field label .req{ color:var(--safety); margin-right:3px; }
.field input, .field select{
  border:1px solid var(--border-lt); background:var(--bg-2); color:var(--text);
  border-radius:9px; padding:11px 13px; font-size:13.5px; font-family:inherit;
  outline:none; transition:border-color .15s, background .15s; width:100%;
}
.field input:focus, .field select:focus{ border-color:var(--safety); background:var(--surface); }
.field input.ltr{ direction:ltr; text-align:left; font-family:'IBM Plex Mono','Vazirmatn',monospace; }
.field input::placeholder{ color:#7c8894; font-family:'Vazirmatn'; font-size:12.5px; }

.field-product{ max-width:360px; margin-bottom:26px; }
.field-product select{
  appearance:none; cursor:pointer; font-weight:700;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa3ab' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat:no-repeat; background-position:left 13px center; background-size:16px;
  padding-left:38px;
}

.submit-row{ margin-top:30px; display:flex; align-items:center; gap:16px; flex-wrap:wrap; }
.btn-primary{
  appearance:none; border:none; cursor:pointer; font-family:inherit;
  background:linear-gradient(160deg, var(--safety) 0%, var(--safety-dark) 100%);
  color:#ffffff; font-size:13.5px; font-weight:800; padding:13px 30px;
  border-radius:9px; box-shadow:var(--shadow-sm); transition:transform .12s, filter .15s;
}
.btn-primary:hover{ filter:brightness(1.08); transform:translateY(-1px); }
.btn-secondary{
  appearance:none; cursor:pointer; font-family:inherit; background:transparent;
  border:1px solid var(--border-lt); color:var(--text); font-size:13px; font-weight:700;
  padding:11px 20px; border-radius:9px;
}
.btn-danger-line{
  appearance:none; cursor:pointer; background:transparent;
  border:1px solid rgba(224,92,78,.4); color:var(--danger); font-size:11.5px; font-weight:700;
  padding:6px 12px; border-radius:7px;
}
.form-hint{ font-size:12px; color:var(--text-dim); }
.alert{
  margin-bottom:22px; padding:13px 16px; border-radius:10px;
  font-size:13px; font-weight:600; border:1px solid;
}
.alert-ok{ background:var(--ok-dim); border-color:#bfe8d1; color:#177a48; }
.alert-err{ background:var(--danger-dim); border-color:#f3c6c0; color:#a83a2e; }

/* ===== admin button ===== */
.btn-admin{
  appearance:none; border:none; cursor:pointer;
  background:linear-gradient(160deg, var(--admin) 0%, var(--admin-dark) 100%);
  color:#100c26; font-size:13px; font-weight:800; padding:11px 22px;
  border-radius:9px; box-shadow:var(--shadow-sm); transition:transform .12s, filter .15s;
  display:inline-flex; align-items:center; gap:8px;
}
.btn-admin:hover{ filter:brightness(1.08); transform:translateY(-1px); }

/* ===== panel (dashboard) ===== */
.panel-body{ min-height:100vh; }
.p-toolbar{ display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; gap:12px; flex-wrap:wrap; }
.stat-chips{ display:flex; gap:8px; flex-wrap:wrap; }
.chip{ font-size:11.5px; padding:6px 12px; border-radius:20px; background:var(--surface); border:1px solid var(--border); color:var(--text-dim); font-weight:600; }
.chip b{ color:var(--heading); font-family:'IBM Plex Mono',monospace; margin-left:4px; }

.req-list{ display:flex; flex-direction:column; gap:12px; }
.req-card{
  border:1px solid var(--border); border-radius:12px;
  background:linear-gradient(175deg, var(--surface-2) 0%, var(--surface) 100%);
  padding:16px 18px; position:relative; overflow:hidden;
  box-shadow: var(--shadow-sm);
}
.req-top{ display:flex; justify-content:space-between; align-items:flex-start; gap:14px; flex-wrap:wrap; }
.req-id{ font-family:'IBM Plex Mono',monospace; color:var(--safety); font-size:12px; font-weight:600; }
.req-name{ font-size:15px; font-weight:800; margin:3px 0 4px; color:var(--heading); }
.req-meta{ font-size:12px; color:var(--text-dim); display:flex; gap:14px; flex-wrap:wrap; }

.type-badge{ font-size:10.5px; font-weight:700; padding:3px 9px; border-radius:6px; }
.type-real{ background:#182338; color:#7ea6e8; }
.type-legal{ background:var(--safety-dim); color:#8fb6f0; }

.status-select, .rep-select{
  border:1px solid var(--border); border-radius:8px; padding:8px 10px; font-family:inherit;
  font-size:12px; font-weight:700; background:var(--bg-2); color:var(--text); cursor:pointer;
}
.req-body{ margin-top:14px; padding-top:14px; border-top:1px dashed var(--border); display:grid; grid-template-columns:1.3fr 1fr; gap:20px; }
@media (max-width:640px){ .req-body{ grid-template-columns:1fr; } }
.detail-grid{ display:grid; grid-template-columns:1fr 1fr; gap:8px 16px; font-size:12.5px; }
.detail-grid div{ color:var(--text-dim); }
.detail-grid div b{ color:var(--text); font-weight:600; display:block; font-size:11px; margin-bottom:2px; }
.detail-grid .v{ font-family:'IBM Plex Mono',monospace; direction:ltr; unicode-bidi:isolate; color:var(--text); }
.rep-row{ display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.rep-row label{ font-size:11.5px; color:var(--text-dim); font-weight:700; }
.note-area{
  border:1px solid var(--border); border-radius:8px; background:var(--bg-2);
  font-family:inherit; font-size:12.5px; color:var(--text); padding:8px 10px; width:100%; resize:vertical; min-height:52px;
}
.save-note-btn{
  margin-top:8px; appearance:none; border:1px solid var(--border-lt); background:var(--surface); cursor:pointer;
  border-radius:7px; padding:6px 14px; font-size:11.5px; font-weight:700; color:var(--text); font-family:inherit;
}
.saved-flag{ font-size:11px; color:var(--ok); margin-right:8px; display:none; }

.stamp{
  position:absolute; left:18px; top:14px;
  width:70px; height:70px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  transform: rotate(-11deg) scale(1); opacity:.95; color:var(--safety);
  pointer-events:none;
}
.stamp svg{ width:100%; height:100%; }
@media (max-width:640px){ .stamp{ left:auto; right:14px; width:56px; height:56px; } }

/* ===== login ===== */
.login-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; background:var(--bg); padding:20px; }
.login-card{ background:linear-gradient(175deg, var(--surface-2) 0%, var(--surface) 100%); border:1px solid var(--border); border-radius:14px; padding:36px 30px; width:100%; max-width:360px; box-shadow:var(--shadow); }
.login-card h1{ font-size:18px; }
.unit-tag{ display:inline-block; font-size:11px; font-weight:700; color:var(--safety); background:var(--safety-dim); padding:4px 10px; border-radius:20px; margin-bottom:14px; }
.login-logo{ display:flex; justify-content:center; margin-bottom:18px; }

/* ===== admin overview cards ===== */
.ov-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-bottom:38px; }
@media (max-width:820px){ .ov-grid{ grid-template-columns:1fr; } }
.ov-card{
  position:relative; text-align:right;
  background:linear-gradient(175deg, var(--surface-2) 0%, var(--surface) 100%);
  border:1px solid var(--border); border-radius:12px;
  padding:20px 18px; overflow:hidden;
  box-shadow: var(--shadow-sm);
}
.ov-card::before, .ov-card::after{
  content:""; position:absolute; width:5px; height:5px; border-radius:50%;
  background:var(--border-lt); box-shadow: inset 0 1px 1px rgba(0,0,0,.6);
}
.ov-card::before{ top:9px; right:9px; }
.ov-card::after{ top:9px; left:9px; }
.ov-unit-name{ font-size:14px; font-weight:800; color:var(--heading); margin-bottom:14px; }
.ov-stats{ display:flex; gap:18px; }
.ov-stat b{ display:block; font-family:'IBM Plex Mono',monospace; font-size:20px; color:var(--heading); }
.ov-stat span{ font-size:11px; color:var(--text-dim); }
.ov-stat.op b{ color:var(--admin); }

/* ===== operators toolbar / list ===== */
.op-toolbar{ display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; gap:12px; flex-wrap:wrap; }
.op-toolbar h2{ font-size:16px; margin:0; color:var(--heading); font-weight:800; }
.op-toolbar .cnt{ font-size:12px; color:var(--text-dim); font-weight:600; margin-right:8px; }

.add-op-card{
  display:none; background:linear-gradient(175deg, var(--surface-2) 0%, var(--surface) 100%);
  border:1px solid var(--admin); border-radius:12px; padding:20px 18px; margin-bottom:20px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(143,124,240,.25);
}
.add-op-card.show{ display:block; }
.add-op-card h3{ margin:0 0 16px; font-size:13.5px; color:var(--heading); font-weight:800; }
.add-op-actions{ margin-top:16px; display:flex; gap:12px; }

.op-list{ display:flex; flex-direction:column; gap:10px; margin-bottom:36px; }
.op-row{
  display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap;
  border:1px solid var(--border); border-radius:10px; padding:12px 16px;
  background:linear-gradient(175deg, var(--surface-2) 0%, var(--surface) 100%);
}
.op-left{ display:flex; align-items:center; gap:12px; }
.op-avatar{
  width:36px; height:36px; border-radius:9px; background:var(--admin-dim); color:var(--admin);
  display:flex; align-items:center; justify-content:center; font-weight:800; font-size:14px; flex-shrink:0;
}
.op-name{ font-size:13.5px; font-weight:700; color:var(--heading); }
.op-meta{ font-size:11.5px; color:var(--text-dim); display:flex; gap:10px; flex-wrap:wrap; margin-top:2px; }
.op-right{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.op-status{ font-size:10.5px; font-weight:700; padding:3px 10px; border-radius:20px; }
.op-status.active{ background:var(--ok-dim); color:var(--ok); }
.op-status.inactive{ background:var(--danger-dim); color:var(--danger); }
.toggle-btn{
  appearance:none; cursor:pointer; background:transparent; border:1px solid var(--border-lt); color:var(--text);
  font-size:11px; font-weight:700; padding:6px 12px; border-radius:7px; font-family:inherit;
}
.icon-btn{
  appearance:none; cursor:pointer; background:transparent; border:1px solid var(--border-lt); color:var(--text-dim);
  width:30px; height:30px; border-radius:7px; display:flex; align-items:center; justify-content:center;
}
.icon-btn svg{ width:14px; height:14px; }
.icon-btn:hover{ color:var(--heading); border-color:var(--border-lt); }

table.plain{ width:100%; border-collapse:collapse; font-size:13px; }
table.plain th{ text-align:right; color:var(--text-dim); font-weight:700; font-size:11.5px; padding:10px 12px; border-bottom:1px solid var(--border); }
table.plain td{ padding:12px; border-bottom:1px solid var(--border); }

.modal-overlay{ display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); align-items:center; justify-content:center; z-index:50; padding:20px; }
.modal-overlay.show{ display:flex; }
.modal-box{ background:var(--surface-2); border:1px solid var(--border); border-radius:14px; padding:24px; width:100%; max-width:380px; box-shadow:var(--shadow); }
.modal-box h3{ margin:0 0 16px; font-size:14.5px; color:var(--heading); }
.modal-actions{ margin-top:18px; display:flex; gap:10px; justify-content:flex-start; }

.install-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; }
.install-card{ background:linear-gradient(175deg, var(--surface-2) 0%, var(--surface) 100%); border:1px solid var(--border); border-radius:14px; padding:36px 32px; width:100%; max-width:420px; box-shadow:var(--shadow); }
.install-card h1{ font-size:18px; margin-bottom:6px; }
