:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-soft: #eef2ef;
  --surface-tint: #f9fbfa;
  --text: #202421;
  --muted: #69726c;
  --border: #dfe5e0;
  --border-strong: #cad5ce;
  --accent: #176f5b;
  --accent-dark: #105243;
  --accent-soft: #e7f3ef;
  --danger: #ad3434;
  --shadow: 0 18px 45px rgba(32, 36, 33, 0.08);
  --shadow-soft: 0 10px 28px rgba(32, 36, 33, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #fbfcfb 0, var(--bg) 360px),
    var(--bg);
  color: var(--text);
  font-family: Vazirmatn, Tahoma, Arial, sans-serif;
  line-height: 1.8;
}

button,
input,
select,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px) 0 48px;
}

.auth-view,
.pending-view {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(100%, 460px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 28px);
}

.topbar,
.section-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head {
  align-items: end;
  justify-content: flex-start;
}

.topbar {
  justify-content: flex-end;
  margin-bottom: 14px;
}

.top-actions,
.pending-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pending-view .pending-actions {
  justify-content: center;
  margin-top: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
}

.lead {
  margin: 12px 0 0;
  color: var(--muted);
}

.pending-text {
  margin: 0;
  color: var(--text);
  font-size: clamp(1rem, 2.4vw, 1.22rem);
  font-weight: 800;
  text-align: center;
}

.lead.error {
  color: var(--danger);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.45;
}

h2 {
  font-size: 1.15rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 18px;
  padding: 5px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.tab-button {
  min-height: 40px;
  background: transparent;
  color: var(--muted);
}

.tab-button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(32, 36, 33, 0.06);
}

.tab-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.admin-panel,
.versions-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.admin-panel {
  margin-bottom: 18px;
  overflow: hidden;
  padding: 0;
}

.versions-section {
  padding: clamp(16px, 3vw, 22px);
}

.hidden {
  display: none !important;
}

.auth-form,
.admin-form {
  display: grid;
  gap: 14px;
}

.admin-form {
  grid-template-columns: 1fr;
  gap: 16px;
  width: min(100%, 680px);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 28px);
}

.panel-head {
  padding: clamp(18px, 3vw, 24px) clamp(18px, 3vw, 28px);
  border-bottom: 1px solid var(--border);
  background: var(--surface-tint);
}

.panel-kicker {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.form-field > span:first-child {
  color: #4f5b54;
  font-size: 0.9rem;
  font-weight: 700;
}

.wide-field {
  grid-column: 1 / -1;
}

input,
select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(23, 111, 91, 0.12);
}

select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) left 18px center / 7px 7px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) left 13px center / 7px 7px no-repeat,
    var(--surface-tint);
  cursor: pointer;
  padding-inline: 40px 14px;
}

input[type='date'] {
  min-height: 52px;
  background:
    linear-gradient(90deg, transparent 0, transparent calc(100% - 54px), var(--accent-soft) calc(100% - 54px)),
    #fff;
  color: var(--text);
  direction: ltr;
  text-align: right;
  font-weight: 600;
}

input[type='date']::-webkit-calendar-picker-indicator {
  width: 22px;
  height: 22px;
  margin-inline-start: 10px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.85;
  padding: 5px;
}

input[type='date']::-webkit-calendar-picker-indicator:hover {
  background: rgba(23, 111, 91, 0.12);
  opacity: 1;
}

button,
.download-button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  padding: 0 16px;
}

button[type='submit'],
.download-button,
#checkApprovalButton {
  background: var(--accent);
  color: #fff;
}

button[type='submit']:hover,
.download-button:hover,
#checkApprovalButton:hover {
  background: var(--accent-dark);
}

button:disabled,
.download-button.disabled {
  cursor: not-allowed;
  opacity: 0.55;
  pointer-events: none;
}

.ghost-button,
.copy-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.submit-button {
  width: 100%;
  margin-top: 4px;
  min-height: 52px;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.ghost-button:hover,
.copy-button:hover {
  background: var(--surface-soft);
}

.text-button {
  min-height: auto;
  margin-top: 14px;
  padding: 4px 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

.message {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.message:empty {
  display: none;
}

.message.error {
  color: var(--danger);
}

.filter-field {
  width: min(100%, 320px);
  gap: 5px;
}

.filter-field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.filter-field select {
  min-height: 44px;
  border-radius: 10px;
  background: var(--surface-tint);
}

.versions-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.version-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.version-info {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(90px, 0.6fr) minmax(130px, 0.9fr);
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.version-cell {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.cell-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.version-name {
  overflow-wrap: anywhere;
  font-size: 1.02rem;
}

.version-number,
.version-date {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.version-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-button {
  min-width: 92px;
}

.download-button {
  min-width: 84px;
}

.empty-state {
  margin: 0;
  padding: 28px 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(360px, calc(100% - 40px));
  border: 1px solid rgba(23, 111, 91, 0.18);
  border-radius: 12px;
  background: #173f36;
  color: #fff;
  box-shadow: 0 18px 40px rgba(20, 35, 30, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  padding: 12px 14px;
  font-size: 0.92rem;
  font-weight: 700;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
  border-color: rgba(173, 52, 52, 0.25);
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 20px, 1040px);
    padding-top: 18px;
  }

  .topbar,
  .section-head,
  .panel-head {
    align-items: flex-start;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .filter-field {
    width: 100%;
  }

  .top-actions,
  .pending-actions,
  .version-row {
    grid-template-columns: 1fr;
  }

  .admin-form {
    padding: 16px;
  }

  .top-actions,
  .pending-actions {
    width: 100%;
    display: grid;
  }

  .version-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .version-info {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .download-button,
  .copy-button {
    width: 100%;
  }

  .toast {
    right: 10px;
    bottom: 10px;
    max-width: calc(100% - 20px);
  }

}

@media (min-width: 681px) and (max-width: 920px) {
  .shell {
    width: min(100% - 28px, 1040px);
  }

  .admin-form {
    width: min(100%, 620px);
  }
}
