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

:root {
  --bg: #eef1f4;
  --bg-deep: #e2e7ed;
  --surface: #f7f8fa;
  --panel: #ffffff;
  --ink: #15202b;
  --ink-soft: #3d4a57;
  --muted: #6b7785;
  --line: #d4dce5;
  --line-strong: #b8c4d1;
  --accent: #0b6e6e;
  --accent-hover: #095858;
  --accent-soft: #e4f3f3;
  --ok: #0f6b45;
  --ok-soft: #e3f5ec;
  --bad: #a12d2d;
  --bad-soft: #f8e6e6;
  --warn: #9a5b00;
  --warn-soft: #fff1d9;
  --shadow: 0 1px 2px rgba(21, 32, 43, 0.04), 0 8px 24px rgba(21, 32, 43, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Vazirmatn", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --header-h: 64px;
  --nav-h: 52px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.65;
  background:
    linear-gradient(180deg, rgba(255,255,255,.55), transparent 180px),
    radial-gradient(900px 420px at 100% -10%, #d7ebea 0%, transparent 55%),
    radial-gradient(700px 360px at 0% 0%, #dfe6f0 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .9rem; }
.full { grid-column: 1 / -1; }

/* —— Login —— */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  position: relative;
  overflow: hidden;
}
.login-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(11,110,110,.08), transparent 40%),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 18px,
      rgba(21,32,43,.02) 18px,
      rgba(21,32,43,.02) 19px
    );
  pointer-events: none;
}
.login {
  position: relative;
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem 1.75rem;
  animation: rise .45s ease both;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.login-mark {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(145deg, #0b6e6e, #184e77);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 500;
  font-size: .85rem;
  letter-spacing: .02em;
  flex-shrink: 0;
}
.login-brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.login-brand p {
  margin: .15rem 0 0;
  color: var(--muted);
  font-size: .82rem;
}
.login form label {
  display: block;
  margin: .9rem 0 .35rem;
  font-size: .82rem;
  font-weight: 500;
  color: var(--ink-soft);
}
.login form label:first-of-type { margin-top: 0; }
.login-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: .75rem;
  align-items: center;
}
.login-actions .btn { flex: 1; justify-content: center; padding: .7rem 1rem; }
#loginError {
  min-height: 1.25rem;
  margin: .85rem 0 0;
  color: var(--bad);
  font-size: .88rem;
}

/* —— App chrome —— */
#appView {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  animation: rise .35s ease both;
}
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  background: rgba(247, 248, 250, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(145deg, #0b6e6e, #184e77);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 500;
  flex-shrink: 0;
}
.brand-lockup h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}
.brand-lockup .sub {
  margin: .1rem 0 0;
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}
.header-actions { display: flex; gap: .5rem; flex-shrink: 0; }

.app-nav {
  position: sticky;
  top: var(--header-h);
  z-index: 30;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.tabs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: .15rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  padding: .95rem 1rem;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  border-radius: 0;
  transition: color .15s ease;
}
.tab:hover { color: var(--ink); }
.tab.active {
  color: var(--accent);
  background: transparent;
}
.tab.active::after {
  content: "";
  position: absolute;
  right: .65rem;
  left: .65rem;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3.5rem;
  flex: 1;
}

.page-intro {
  margin: 0 0 1.25rem;
}
.page-intro h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.page-intro p {
  margin: .35rem 0 0;
  color: var(--muted);
  font-size: .92rem;
  max-width: 62ch;
}

/* —— Panels / cards —— */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
}
.card h2 {
  margin: 0 0 .2rem;
  font-size: 1.02rem;
  font-weight: 700;
}
.card > .section-desc {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: .86rem;
}
.card h3 {
  margin: 1.25rem 0 .65rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: .01em;
}
.card h3:first-of-type {
  margin-top: .35rem;
  padding-top: 0;
  border-top: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel-head h2 { margin: 0; }
.panel-kicker {
  display: inline-block;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .35rem;
}

.grid { display: grid; gap: .9rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.brand-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: .35rem;
}
label .muted {
  font-weight: 400;
  margin-inline-start: .25rem;
}
.field-hint {
  margin: .35rem 0 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}
.field-hint code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .78rem;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .62rem .75rem;
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, textarea:hover, select:hover { border-color: #9aa8b8; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 110, 110, .15);
}
textarea { min-height: 96px; resize: vertical; }
textarea.code {
  min-height: 320px;
  font-family: var(--mono);
  font-size: .84rem;
  line-height: 1.55;
}
input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .9rem;
  padding: .75rem .9rem;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  border: 1px solid #c7e4e4;
}
.checkbox-row label {
  margin: 0;
  color: var(--ink);
  font-size: .9rem;
  cursor: pointer;
}

.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.field-actions { margin-top: .5rem; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .52rem .9rem;
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--accent);
  color: #fff;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn.secondary:hover { background: var(--surface); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #8a2424; }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #0c5939; }
.btn.warn { background: #c97816; }
.btn.warn:hover { background: #a86210; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
a.btn {
  text-decoration: none;
  line-height: 1.25;
}
a.btn:hover { text-decoration: none; color: inherit; }
a.btn.secondary:hover { color: var(--ink); }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: .18rem .5rem;
  font-size: .74rem;
  font-weight: 600;
  font-family: var(--mono);
  background: var(--bg-deep);
  color: var(--ink-soft);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

.table-wrap { overflow-x: auto; margin: 0 -.25rem; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.table th, .table td {
  border-bottom: 1px solid var(--line);
  padding: .85rem .5rem;
  text-align: right;
  vertical-align: top;
}
.table th {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
  letter-spacing: .01em;
}
.table tr:last-child td { border-bottom: 0; }
.thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  margin-inline-end: .65rem;
  vertical-align: middle;
  border: 1px solid var(--line);
}

.test-out {
  margin-top: .55rem;
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .65rem .75rem;
  font-family: var(--mono);
  font-size: .76rem;
  line-height: 1.5;
  display: none;
}
.test-out.show { display: block; }

/* Checklist */
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .45rem;
}
.checklist li {
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .55rem .65rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: .86rem;
  color: var(--ink-soft);
}
.checklist li .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: .45rem;
  flex-shrink: 0;
  background: var(--line-strong);
}
.checklist li.is-ok .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.checklist li.is-ok { border-color: #c6e5d5; background: #f4fbf7; }

/* Brand action cards */
.brand-card h2 {
  margin: 0;
  font-size: 1.15rem;
}
.brand-card .quota-line {
  margin: .65rem 0 1rem;
  font-size: .9rem;
  color: var(--ink-soft);
}
.brand-card .run-actions {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.brand-card .run-actions .btn { justify-content: center; width: 100%; }
.brand-card .status-msg {
  margin: .85rem 0 0;
  min-height: 1.2rem;
  font-size: .86rem;
}

/* Settings sticky save */
.settings-savebar {
  position: sticky;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  background: rgba(21, 32, 43, .92);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(21, 32, 43, .22);
  backdrop-filter: blur(8px);
}
.settings-savebar .muted { color: rgba(255,255,255,.7); }
.settings-savebar .btn.ok {
  background: #2bb673;
}
.settings-savebar .btn.ok:hover { background: #24a064; }

.settings-jump {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: 0 0 1rem;
}
.settings-jump a {
  font-size: .78rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .3rem .7rem;
  text-decoration: none;
}
.settings-jump a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  padding: .9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.filters > div { min-width: 160px; flex: 1; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 860px) {
  .grid.two, .brand-grid { grid-template-columns: 1fr; }
  .brand-lockup .sub { display: none; }
  .app-header { padding: 0 1rem; }
  main { padding: 1.15rem 1rem 3rem; }
  .tabs { padding: 0 1rem; }
  .checklist { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
