/* ==========================================================================
   Auction Manager — web UI
   Same design language as the extension: Inter for Latin, Sahel behind it for
   Persian. Inter ships no Arabic glyphs, so Persian falls through on its own.
   ========================================================================== */

:root,
[data-theme='dark'] {
  color-scheme: dark;
  --surface-base: #0b0d12;
  --surface-1: #12151d;
  --surface-2: #181c26;
  --surface-3: #1f2430;
  --surface-inset: #0e1016;
  --border: #262c3a;
  --border-strong: #333a4b;
  --border-subtle: #1c212c;
  --text: #e6e9f0;
  --text-strong: #ffffff;
  --text-muted: #9aa3b8;
  --text-faint: #6b7489;
  --accent: #6d7cff;
  --accent-hover: #5a6bf5;
  --accent-active: #4c5de8;
  --accent-soft: #1a1f3d;
  --accent-text: #ffffff;
  --accent-ring: rgb(109 124 255 / 45%);
  --success: #4ade80;
  --success-soft: #0f2a1c;
  --warning: #fbbf24;
  --warning-soft: #2b2110;
  --danger: #f87171;
  --danger-soft: #2d1416;
  --danger-border: #4d2226;
  --info: #7dd3fc;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-md: 0 4px 16px -4px rgb(0 0 0 / 50%);
  --scrollbar-thumb: #2e3546;
}

[data-theme='light'] {
  color-scheme: light;
  --surface-base: #f6f7fb;
  --surface-1: #ffffff;
  --surface-2: #f2f4f9;
  --surface-3: #e9ecf4;
  --surface-inset: #ffffff;
  --border: #dfe3ed;
  --border-strong: #c9cfdd;
  --border-subtle: #eaedf4;
  --text: #1b1f2c;
  --text-strong: #0a0d15;
  --text-muted: #5f6880;
  --text-faint: #8a92a6;
  --accent: #4f5ee8;
  --accent-hover: #4250d6;
  --accent-active: #3742bd;
  --accent-soft: #eaecff;
  --accent-text: #ffffff;
  --accent-ring: rgb(79 94 232 / 35%);
  --success: #15803d;
  --success-soft: #e7f7ec;
  --warning: #b45309;
  --warning-soft: #fdf3e0;
  --danger: #c2333a;
  --danger-soft: #fdeced;
  --danger-border: #f3c2c5;
  --info: #0369a1;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%);
  --shadow-md: 0 4px 16px -4px rgb(16 24 40 / 12%);
  --scrollbar-thumb: #cfd5e2;
}

:root {
  --font: 'SF Pro Text', 'Sahel', sans-serif;
  --font-mono: 'SF Mono', ui-monospace, 'Cascadia Mono', Menlo, monospace;
  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 13px;
  --r-full: 999px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 22px;
  --sp-6: 30px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --dur: 160ms;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--surface-base);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Hidden until the theme is applied, so there is no light flash. */
html:not([data-theme]) body {
  visibility: hidden;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border: 3px solid var(--surface-base);
  border-radius: var(--r-full);
}

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

h1 {
  font-size: 16px;
  font-weight: 650;
  color: var(--text-strong);
  letter-spacing: -0.015em;
}
h2 {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text-strong);
}

.hint {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
}
.meta {
  font-size: 12px;
  color: var(--text-muted);
}
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}
.spacer {
  flex: 1;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad {
  padding: var(--sp-4);
}

.divider {
  height: 1px;
  background: var(--border-subtle);
  border: 0;
  margin: var(--sp-1) 0;
}

/* ─── gate ───────────────────────────────────────────────────────────────── */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
}
.gate-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* ─── chrome ─────────────────────────────────────────────────────────────── */

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.brand {
  font-size: 14px;
  color: var(--text-strong);
}

.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--r-md);
}
.tab {
  padding: 6px 13px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab:hover {
  color: var(--text);
}
.tab.is-active {
  background: var(--surface-1);
  color: var(--text-strong);
  box-shadow: var(--shadow-sm);
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  align-items: start;
}
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
@media (max-width: 860px) {
  .grid-2,
  .split {
    grid-template-columns: 1fr;
  }
}

/* ─── stats ──────────────────────────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3);
}
.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.stat-value {
  font-size: 22px;
  font-weight: 650;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.stat-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ─── controls ───────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > label {
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-muted);
}

.input,
.select {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder {
  color: var(--text-faint);
}
.input:hover:not(:disabled),
.select:hover:not(:disabled) {
  border-color: var(--border-strong);
}
.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.input:disabled,
.select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.select {
  appearance: none;
  padding-inline-end: 30px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentcolor 50%),
    linear-gradient(135deg, currentcolor 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% + 1px), calc(100% - 11px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: transparent;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text);
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}
.btn-icon {
  padding: 8px;
}
.btn-icon svg {
  width: 16px;
  height: 16px;
}

.btn.is-busy {
  color: transparent;
  pointer-events: none;
  position: relative;
}
.btn.is-busy::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid currentcolor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--accent-text);
  animation: spin 620ms linear infinite;
}
.btn:not(.btn-primary).is-busy::after {
  color: var(--text-muted);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
}
.theme-toggle:hover {
  background: var(--surface-3);
  color: var(--text);
}
.theme-toggle svg {
  width: 15px;
  height: 15px;
}
[data-theme='dark'] .theme-toggle .icon-moon,
[data-theme='light'] .theme-toggle .icon-sun {
  display: none;
}

/* ─── badges, chips, notices ─────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.7;
  background: var(--surface-3);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge-ok {
  background: var(--success-soft);
  color: var(--success);
}
.badge-warn {
  background: var(--warning-soft);
  color: var(--warning);
}
.badge-err {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.dot-accent {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 11px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  font-size: 12.5px;
}
.chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.chip button:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.notice {
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
.notice-err {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}
.notice-ok {
  background: var(--success-soft);
  border-color: transparent;
  color: var(--success);
}

.empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--text-faint);
}

/* ─── captcha ────────────────────────────────────────────────────────────── */

.captcha-row {
  display: flex;
  align-items: stretch;
  gap: var(--sp-2);
}
.captcha-img {
  display: grid;
  place-items: center;
  min-width: 150px;
  min-height: 42px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.captcha-img img {
  max-height: 42px;
  display: block;
}
.captcha-input {
  max-width: 130px;
  text-align: center;
  letter-spacing: 0.25em;
}

/* ─── table ──────────────────────────────────────────────────────────────── */

.toolbar {
  flex-wrap: wrap;
}
.search {
  position: relative;
}
.search .input {
  width: 300px;
  max-width: 100%;
  padding-inline-start: 34px;
}
.search svg {
  position: absolute;
  inset-inline-start: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}

.table-card {
  overflow: hidden;
}
.table-scroll {
  overflow-x: auto;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  padding: 11px 13px;
  text-align: start;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 13px;
  vertical-align: top;
  border-bottom: 1px solid var(--border-subtle);
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: var(--surface-2);
}

.col-no {
  width: 150px;
}
.col-desc {
  min-width: 280px;
}
.col-org {
  min-width: 190px;
}
.col-deadline {
  width: 150px;
}
.col-contact {
  width: 180px;
}
.col-file {
  width: 90px;
}

.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.clamp.open {
  -webkit-line-clamp: unset;
}

.phone {
  display: block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--info);
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}
.muted {
  color: var(--text-faint);
}

/* ─── toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  inset-inline: 0;
  bottom: var(--sp-5);
  margin-inline: auto;
  width: fit-content;
  max-width: min(520px, 92vw);
  padding: 11px 16px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  z-index: 50;
}
.toast.err {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}
.toast.ok {
  background: var(--success-soft);
  border-color: transparent;
  color: var(--success);
}

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