:root {
  --bg0: #0f1c18;
  --bg1: #1a3229;
  --ink: #12201b;
  --paper: #f4f7f4;
  --panel: rgba(255, 252, 247, 0.92);
  --line: rgba(18, 32, 27, 0.12);
  --muted: #5a6e65;
  --accent: #0f766e;
  --accent-2: #c45c26;
  --ok: #1b7a4a;
  --warn: #a15c00;
  --bad: #b42318;
  --shadow: 0 18px 50px rgba(8, 20, 16, 0.28);
  --radius: 18px;
  --font: "Instrument Sans", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(196, 92, 38, 0.28), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(15, 118, 110, 0.35), transparent 50%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 55%, #243f35);
}

.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 100vh;
}

.auth-shell, .app-shell { width: min(1120px, 100%); }

.auth-panel, .panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(420px, 100%);
  padding: 36px 32px;
}

.brand {
  font-family: var(--display);
  font-size: 1.55rem;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.auth-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.auth-top .brand { margin-bottom: 0; }

.lang-switch {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(18, 32, 27, 0.08);
  border: 1px solid var(--line);
}
.auth-body .lang-switch,
.topbar .lang-switch {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}
.auth-panel .lang-switch {
  background: rgba(18, 32, 27, 0.06);
  border-color: var(--line);
}
.lang-switch button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.topbar .lang-switch button {
  color: rgba(232, 245, 239, 0.78);
}
.auth-panel .lang-switch button { color: var(--muted); }
.lang-switch button.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.topbar .lang-switch button.active {
  background: rgba(255,255,255,0.95);
  color: var(--accent);
}

h1, h2 {
  font-family: var(--display);
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

.lede, .muted { color: var(--muted); line-height: 1.5; }
.stack { display: grid; gap: 14px; margin-top: 22px; }
label { display: grid; gap: 6px; font-size: 0.92rem; font-weight: 500; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  border-color: var(--accent);
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: #e7eeea; color: var(--ink); }
.btn.ghost { background: transparent; color: #dff2ea; border: 1px solid rgba(255,255,255,.25); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.auth-links {
  margin: 0;
  text-align: center;
}
.linkish {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.auth-links a {
  color: var(--accent);
  font-weight: 600;
}
.ok-msg {
  margin: 0;
  color: var(--ok);
  font-size: .92rem;
}

.app-shell { margin: 0; padding: 0; width: 100%; max-width: none; }

/* ===== Admin sidebar layout ===== */
.admin-body {
  background: #eef2f0 !important;
  min-height: 100vh;
}
.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  width: 100%;
}
.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #10231d 0%, #16352b 55%, #1a3f33 100%);
  color: #e8f5ef;
  padding: 20px 14px;
  border-right: 1px solid rgba(255,255,255,.06);
  z-index: 40;
}
.sidebar-brand {
  padding: 8px 12px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 16px;
}
.sidebar-logo {
  font-family: var(--display);
  font-size: 1.35rem;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.sidebar-tag {
  margin: 6px 0 0;
  font-size: .78rem;
  color: rgba(232,245,239,.55);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.sidebar-nav {
  display: grid;
  gap: 6px;
  flex: 1;
  align-content: start;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: rgba(232,245,239,.78);
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: .95rem;
  transition: background .15s ease, color .15s ease;
}
.sidebar-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.sidebar-link.active {
  background: #fff;
  color: var(--accent);
}
.sidebar-ico {
  width: 22px;
  text-align: center;
  opacity: .9;
  font-size: 1rem;
}
.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: grid;
  gap: 12px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}
.sidebar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(15,118,110,.35);
  border: 1px solid rgba(255,255,255,.15);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-weight: 600;
  font-size: .88rem;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-role {
  font-size: .75rem;
  color: rgba(232,245,239,.55);
}
.sidebar-logout {
  width: 100%;
  background: rgba(255,255,255,.08);
  color: #e8f5ef;
  border: 1px solid rgba(255,255,255,.12);
}
.sidebar-logout:hover { background: rgba(255,255,255,.14); }

.admin-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(255,252,247,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.page-title {
  font-family: var(--display);
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: -0.02em;
}
.page-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: .85rem;
}
.sidebar-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
}
.admin-topbar .lang-switch {
  background: rgba(18, 32, 27, 0.06);
  border-color: var(--line);
}
.admin-topbar .lang-switch button { color: var(--muted); }
.admin-topbar .lang-switch button.active {
  background: #fff;
  color: var(--accent);
}

.admin-content {
  padding: 22px 24px 40px;
  width: min(1180px, 100%);
}
.admin-content .panel {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(16, 35, 29, 0.06);
}
.sidebar-backdrop {
  display: none;
}

@media (max-width: 920px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
  }
  body.sidebar-open .admin-sidebar { transform: translateX(0); }
  .sidebar-toggle { display: inline-grid; place-items: center; }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 16, 14, .45);
    z-index: 30;
  }
  .admin-content { padding: 16px; width: 100%; }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.panel-head h2 { margin: 0; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.stat-card {
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.stat-value {
  font-family: var(--display);
  font-size: 1.7rem;
  line-height: 1;
  color: var(--accent);
}
.stat-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: .88rem;
}
.page-narrow { max-width: 720px; }
.jobs-page { max-height: none; }
.results-table { max-height: 620px; }
.job-summary {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7faf8;
  padding: 14px;
  margin: 12px 0;
}
a.job-card.link-card {
  text-decoration: none;
  color: inherit;
  display: block;
}
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.layout {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 16px;
}
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
}

.panel { padding: 22px; }
.panel h2 { font-size: 1.35rem; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0 16px;
}
.tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab.active {
  background: rgba(15, 118, 110, 0.12);
  border-color: rgba(15, 118, 110, 0.35);
  color: var(--accent);
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.job-list { display: grid; gap: 10px; margin-top: 14px; max-height: 520px; overflow: auto; }
.job-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  cursor: pointer;
}
.job-card.active { border-color: rgba(15,118,110,.45); box-shadow: inset 0 0 0 1px rgba(15,118,110,.2); }
.job-card .row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge.queued { background: #eef2f0; color: var(--muted); }
.badge.running { background: #fff4df; color: var(--warn); }
.badge.completed { background: #e5f6ec; color: var(--ok); }
.badge.failed { background: #fde8e6; color: var(--bad); }

.progress {
  height: 8px;
  border-radius: 999px;
  background: #e7eeea;
  overflow: hidden;
  margin-top: 10px;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #2aa89d);
  width: 0%;
  transition: width .25s ease;
}

.table-wrap {
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  max-height: 420px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: #f0f5f2;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
a { color: var(--accent); }

.hidden { display: none !important; }
.hint { font-size: .88rem; color: var(--muted); margin: 0 0 8px; }

.admin-sub {
  font-family: var(--display);
  font-size: 1.1rem;
  margin: 0 0 10px;
}
.admin-form {
  margin-top: 0;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.admin-table { max-height: 360px; }
.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  grid-template-columns: none !important;
}
.check-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.btn.tiny {
  padding: 6px 10px;
  font-size: .8rem;
  border-radius: 8px;
}
.btn.danger {
  background: #fde8e6;
  color: var(--bad);
}
.badge.on { background: #e5f6ec; color: var(--ok); }
.badge.off { background: #eef2f0; color: var(--muted); }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-bar {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 0.7fr auto auto auto;
  gap: 10px;
  align-items: end;
  margin: 12px 0 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7faf8;
}
.filter-bar label { margin: 0; gap: 4px; font-size: .82rem; }
.filter-check {
  padding-bottom: 10px;
  white-space: nowrap;
}
.filter-actions {
  display: flex;
  gap: 8px;
  padding-bottom: 2px;
}
.contacts-table { max-height: 620px; }
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}
@media (max-width: 1100px) {
  .filter-bar { grid-template-columns: 1fr 1fr; }
}
