:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e2e8f2;
  --text: #16233b;
  --muted: #6b7a90;
  --accent: #1f6feb;
  --ok: #12855a;
  --danger: #c92a2a;
  --radius: 14px;
  --shadow: 0 6px 22px rgba(22, 35, 59, .07);
}

* { box-sizing: border-box; }

/* attribute hidden باید بر هر display دستی اولویت داشته باشد */
[hidden] { display: none !important; }

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif; font-size: 14px; line-height: 1.85;
}

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.4; }
h1 { font-size: 1rem; }
h2 { font-size: .95rem; color: #123a6b; }
h3 { font-size: .86rem; color: #123a6b; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.2rem; background: var(--panel); border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.logo-mark {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px;
  background: linear-gradient(140deg, var(--accent), #7c5cff); color: #fff; font-size: 17px;
}
.sub { margin: 0; font-size: .76rem; color: var(--muted); }
.actions { display: flex; gap: .5rem; align-items: center; }
.badge {
  font-size: .72rem; padding: .2rem .6rem; border-radius: 999px;
  background: #eef4ff; color: #1f4fa8; border: 1px solid #d6e4ff;
}

.btn, .btn-ghost {
  font-family: inherit; font-size: .8rem; border-radius: 9px; cursor: pointer;
  padding: .35rem .8rem; border: 1px solid var(--line); background: #fff; color: var(--text);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:hover, .btn-ghost:hover { filter: brightness(.97); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }

.center-card { display: grid; place-items: center; min-height: 70vh; padding: 1rem; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; box-shadow: var(--shadow);
}
.center-card .card { width: min(420px, 92vw); }
.hint { font-size: .76rem; color: var(--muted); margin: .2rem 0 .6rem; }
.error { color: var(--danger); font-size: .8rem; }

label { display: block; font-size: .78rem; color: #33465f; margin-bottom: .55rem; }
input, select, textarea {
  width: 100%; font-family: inherit; font-size: .84rem; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: .4rem .55rem;
  background: #fbfcfe; margin-top: .2rem;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: #bcd3ff; background: #fff; }
label.row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
label.row input[type="checkbox"] { width: auto; }
.mono { font-family: Consolas, monospace; direction: ltr; display: inline-block; }

main { max-width: 1240px; margin: 0 auto; padding: 1rem; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.toolbar-actions { display: flex; gap: .5rem; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: .9rem; align-items: start; }
@media (max-width: 980px) { .grid { grid-template-columns: 1fr; } }

.table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: .45rem .4rem; text-align: right; }
.table th { color: var(--muted); font-weight: 600; font-size: .76rem; background: #f8fafd; }
.table.small { font-size: .76rem; margin-top: .6rem; }
.table tbody tr:hover { background: #f8fafd; }
.pill { font-size: .7rem; padding: 0 .45rem; border-radius: 999px; border: 1px solid var(--line); }
.pill.ok { background: #e9f8f0; color: #0d6b48; border-color: #c7ebd8; }
.pill.warn { background: #fdf7ea; color: #8a5a00; border-color: #f2dcb0; }
.pill.off { background: #fdeceb; color: #8f1d1d; border-color: #f3c2c2; }

.events { list-style: none; margin: 0; padding: 0; font-size: .78rem; color: #33465f; }
.events li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.events .when { color: var(--muted); font-size: .72rem; }

.panel { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.panel-head div { display: flex; gap: .5rem; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: .9rem; }
.card.wide { grid-column: 1 / -1; }

.logo-preview {
  height: 90px; display: grid; place-items: center; border: 1px dashed var(--line);
  border-radius: 10px; background: #fbfcfe; margin-bottom: .5rem;
}
.logo-preview img { max-height: 78px; max-width: 90%; object-fit: contain; }

.list { list-style: none; margin: 0; padding: 0; font-size: .8rem; }
.list li { padding: .32rem 0; border-bottom: 1px dashed var(--line); }
.list .meta { color: var(--muted); font-size: .74rem; }

.split { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: .8rem; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
.convs { max-height: 320px; overflow-y: auto; }
.convs li { cursor: pointer; padding: .45rem .5rem; border-radius: 8px; }
.convs li:hover { background: #f2f6fd; }
.convs li.active { background: #eef4ff; }
.turns { max-height: 320px; overflow-y: auto; font-size: .8rem; }
.turn { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .6rem; margin-bottom: .5rem; }
.turn .q { font-weight: 600; color: #123a6b; }
.turn .a { color: #33465f; white-space: pre-wrap; max-height: 150px; overflow: hidden; }
.turn .m { color: var(--muted); font-size: .72rem; }

.modal {
  position: fixed; inset: 0; background: rgba(15, 25, 45, .45);
  display: grid; place-items: center; z-index: 50; padding: 1rem;
}
.modal-card { width: min(460px, 94vw); max-height: 90vh; overflow-y: auto; }
.modal-actions { display: flex; gap: .5rem; margin-top: .6rem; }

/* --- خروجی رمز یک‌بارمصرف --- */
.password-out {
  margin-top: .6rem; padding: .55rem .7rem; border-radius: 10px; font-size: .82rem;
  background: #e9f8f0; border: 1px solid #c7ebd8; color: #0d6b48;
}
.password-out .pw { font-family: Consolas, monospace; direction: ltr; font-weight: 700; font-size: .95rem; }
.user-row { display: flex; align-items: center; gap: .4rem; justify-content: space-between; }
.user-row .meta { display: block; }
