@font-face {
  font-family: "Vazirmatn FD";
  src: url("fonts/Vazirmatn-FD-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn FD";
  src: url("fonts/Vazirmatn-FD-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #f4fff7;
  --muted: #b7d7c0;
  --line: rgba(167, 230, 176, 0.18);
  --card: rgba(6, 28, 16, 0.78);
  --green: #3ddc6a;
  --green-deep: #07160d;
  --leaf: #8dff6a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--app-font, "Vazirmatn FD", Tahoma, sans-serif);
  color: var(--ink);
  background: #041108 url("field-bg.jpg") center / cover no-repeat fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 0%, rgba(61, 220, 106, 0.16), transparent 32%),
    linear-gradient(180deg, rgba(3, 14, 8, 0.42), rgba(3, 12, 8, 0.72));
}

#app { position: relative; z-index: 1; min-height: 100vh; }

button, input, select, textarea { font: inherit; color: inherit; }

button {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  background: linear-gradient(180deg, #7dff6b, #2fbe58);
  color: #06210f;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: rgba(8, 32, 18, 0.55);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 500;
}

h1, h2, p { margin: 0; }

.hazard { height: 3px; background: linear-gradient(90deg, transparent, var(--leaf), transparent); }

.gate {
  min-height: 100vh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 2rem;
}

.gate-card, .panel, .stat, .backup-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.gate-card {
  width: min(480px, 100%);
  padding: 1.7rem;
  display: grid;
  gap: 0.85rem;
}

.mark { width: 72px; height: 72px; justify-self: center; }
.eyebrow {
  justify-self: center;
  color: var(--leaf);
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}
.gate-card h1 { text-align: center; }
.gate-card p, .hint, .empty { color: var(--muted); line-height: 1.8; }
.choices { display: flex; gap: 0.6rem; }

.shell { display: grid; grid-template-rows: auto auto 1fr; height: 100vh; }

header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1.25rem 1rem;
  background: rgba(5, 20, 12, 0.62);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 0.85rem; }
.logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 16px;
  background: rgba(8, 40, 20, 0.8);
  border: 1px solid var(--line);
  padding: 4px;
}
.app-title { color: var(--leaf); font-size: 0.78rem; margin-bottom: 0.15rem; }
header h1 { font-size: 1.35rem; }
.shop-meta { color: var(--muted); margin-top: 0.35rem; font-size: 0.82rem; line-height: 1.6; }
.who { display: grid; justify-items: end; gap: 0.45rem; color: var(--muted); font-size: 0.85rem; }
header button.secondary { background: transparent; color: var(--leaf); border-color: rgba(125, 255, 107, 0.45); }

.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 0; }

nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem;
  background: rgba(4, 18, 10, 0.55);
  backdrop-filter: blur(12px);
  border-left: 1px solid var(--line);
  overflow: auto;
}

nav button {
  text-align: right;
  background: transparent;
  color: #e7f6ea;
  border-radius: 14px;
  font-weight: 500;
  padding: 0.62rem 0.8rem;
}

nav button.active {
  background: linear-gradient(180deg, #7dff6b, #2fbe58);
  color: #06210f;
}

main { padding: 1.15rem; display: grid; gap: 1rem; align-content: start; grid-auto-rows: max-content; overflow: auto; }

.banner { padding: 0.75rem 0.95rem; border-radius: 14px; }
.banner.error { background: rgba(141, 43, 31, 0.85); color: #fff4f1; }
.banner.ok { background: rgba(22, 92, 48, 0.85); color: #e9ffe9; }

.form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}
.form label, .stack { display: grid; gap: 0.28rem; color: var(--muted); font-size: 0.85rem; }
.form label.wide, .wide { grid-column: 1 / -1; }
.form input, .form select, .form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  color: var(--ink);
  background: rgba(3, 16, 9, 0.72);
}
.form option { color: #102116; background: #eef8ef; }
.actions, .row-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; }
button.danger { background: #c44736; color: white; }
button.small { padding: 0.35rem 0.65rem; border-radius: 10px; }
.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; }
.stat {
  padding: 0.95rem 1rem;
  display: grid;
  gap: 0.35rem;
  border-top: 3px solid var(--leaf);
}
.stat span { color: var(--muted); font-size: 0.85rem; }
.stat strong { font-size: 1.2rem; color: var(--leaf); }

.panel, .backup-card { padding: 1rem 1.05rem; overflow: auto; }
.panel h2, .backup-card h2 {
  margin-bottom: 0.8rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.15rem;
}
.section-label { grid-column: 1 / -1; color: var(--leaf); font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
th { color: var(--leaf); font-weight: 600; background: rgba(125, 255, 107, 0.08); }

.backup-card {
  display: grid;
  gap: 0.7rem;
  background:
    linear-gradient(180deg, rgba(125, 255, 107, 0.12), transparent 46%),
    var(--card);
}

@media (max-width: 900px) {
  .form, .totals, .layout, .stats { grid-template-columns: 1fr; }
  header, .who { align-items: start; }
  .who { justify-items: start; }
}

.footer-lines { display: grid; gap: 8px; }
.footer-lines > span { font-weight: 600; }
#footer-lines { display: grid; gap: 6px; }
.footer-line { display: flex; gap: 8px; align-items: center; }
.footer-line input { flex: 1; }

.sync-chip { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; }
.sync-chip:empty { display: none; }
.sync-chip .dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #3a8d3a; }
.sync-chip .dot.pending { background: #d99a1e; }
.sync-chip .dot.offline, .sync-chip .dot.signed-out { background: #8a8a8a; }
.sync-chip .dot.error { background: #c0392b; }
#sync-alert ul { margin: 0.3rem 1.2rem; }
.dev-credit { margin: 24px 0 8px; text-align: center; color: var(--muted); font-size: 0.85rem; }

input, select, textarea, button { font-family: inherit; }
.theme-presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.theme-preset { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
input[type="color"] { min-height: 40px; padding: 2px; }
