:root {
  --wysh-bg: #f0f2f5;
  --wysh-card: rgba(255, 255, 255, 0.82);
  --wysh-border: rgba(15, 23, 42, 0.08);
  --wysh-text: #1e293b;
  --wysh-muted: #64748b;
  --wysh-accent: #475569;
  --wysh-accent-hover: #334155;
  --danger: #b91c1c;
  --ok: #15803d;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font);
  color: var(--wysh-text);
  background: var(--wysh-bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(148, 163, 184, 0.22), transparent 55%),
    radial-gradient(ellipse 90% 60% at 100% 100%, rgba(203, 213, 225, 0.35), transparent 50%);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

h1, h2 {
  margin: 0 0 8px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--wysh-text);
}

.muted { color: var(--wysh-muted); margin: 0; }

/* —— Shared form controls (fin_site) —— */
.form-label {
  display: block;
  font-weight: 500;
  color: var(--wysh-text);
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
}

.form-control {
  display: block;
  width: 100%;
  font: inherit;
  color: var(--wysh-text);
  background: #fff;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: rgba(71, 85, 105, 0.45);
  box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.12);
}

/* —— Buttons (fin_site products.php / login.php) —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.25;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-icon {
  flex-shrink: 0;
  display: block;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(180deg, #64748b 0%, var(--wysh-accent) 100%);
  border: none;
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #576275 0%, var(--wysh-accent-hover) 100%);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px rgba(15, 23, 42, 0.2);
  color: #fff;
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-outline-primary {
  border: 1px solid rgba(71, 85, 105, 0.45);
  color: var(--wysh-accent);
  background: #fff;
}

.btn-outline-primary:hover:not(:disabled) {
  background: rgba(71, 85, 105, 0.1);
  border-color: var(--wysh-accent-hover);
  color: var(--wysh-accent-hover);
  transform: translateY(-1px);
}

.btn-outline-secondary {
  border: 1px solid rgba(71, 85, 105, 0.35);
  color: var(--wysh-accent);
  background: #fff;
}

.btn-outline-secondary:hover:not(:disabled) {
  background: rgba(71, 85, 105, 0.08);
  border-color: rgba(71, 85, 105, 0.5);
  color: var(--wysh-accent-hover);
  transform: translateY(-1px);
}

.btn-logout {
  border: 1px solid rgba(71, 85, 105, 0.25);
  background: #fff;
  color: var(--wysh-muted);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.4rem 1rem;
}

.btn-logout:hover:not(:disabled) {
  border-color: rgba(220, 38, 38, 0.4);
  color: #b91c1c;
  background: rgba(254, 242, 242, 0.8);
  transform: none;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.btn-ghost {
  background: transparent;
  border-color: rgba(15, 23, 42, 0.12);
  color: var(--wysh-muted);
  font-weight: 500;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(15, 23, 42, 0.04);
  color: var(--wysh-text);
}

/* —— Login 1:1 fin_site/login.php —— */
body.login-mode {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

body.login-mode #app {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}

.login-shell {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.login-form {
  padding: 2rem 2rem 1.75rem;
  border-radius: 20px;
  background: var(--wysh-card);
  border: 1px solid var(--wysh-border);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 24px 48px -12px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.login-form .login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-form .login-brand img {
  max-height: 56px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(15, 23, 42, 0.08));
}

.login-form .field-mb-3 {
  margin-bottom: 1rem;
}

.login-form .field-mb-4 {
  margin-bottom: 1.5rem;
}

.login-footer {
  text-align: center;
  margin: 1.25rem 0 0;
  font-size: 0.75rem;
  color: var(--wysh-muted);
}

.alert {
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-danger {
  border: 1px solid rgba(220, 38, 38, 0.15);
  background: #fef2f2;
  color: var(--danger);
}

.alert[hidden] {
  display: none !important;
}

/* —— Dashboard —— */
.topbar.navbar-wysh {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
  padding: 0.6rem 1.1rem;
  background: var(--wysh-card);
  border: 1px solid var(--wysh-border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.wysh-nav-logo {
  max-height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(15, 23, 42, 0.06));
}

.topbar-titles {
  min-width: 0;
}

.topbar-titles h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.topbar-titles .muted {
  font-size: 0.85rem;
  margin-top: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.whoami {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--wysh-muted);
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.04);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.card {
  border: 1px solid var(--wysh-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  background: rgba(255, 255, 255, 0.85);
  padding: 18px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.card h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.card p {
  margin: 0;
  color: var(--wysh-muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.days-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.days-row .form-label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.days-row .form-control {
  width: 88px;
  padding: 0.5rem 0.65rem;
}

.panel {
  background: var(--wysh-card);
  border: 1px solid var(--wysh-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 24px;
}

.runs-panel h2 { font-size: 1.05rem; margin-bottom: 14px; }

.runs {
  display: grid;
  gap: 12px;
}

.run {
  border: 1px solid var(--wysh-border);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.run-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.run-title { font-weight: 600; }
.run-meta {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--wysh-muted);
}

.progress {
  height: 8px;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #64748b, var(--wysh-accent));
  transition: width 0.35s ease;
}

.run.status-error .progress > span { background: var(--danger); }
.run.status-success .progress > span { background: var(--ok); }

.stages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.stage {
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--wysh-border);
  color: var(--wysh-muted);
  background: #fff;
}

.stage.done {
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  color: var(--ok);
  background: #edf8f0;
}

.stage.active {
  border-color: color-mix(in srgb, var(--wysh-accent) 45%, transparent);
  color: var(--wysh-accent-hover);
  background: #eef2f6;
  font-weight: 500;
}

.runs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.runs-head h2 { margin: 0; }

.run-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.run-delete {
  flex-shrink: 0;
  min-width: 32px;
  padding: 4px 8px;
  line-height: 1;
}

.run-msg {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--wysh-muted);
}

.run-msg.error,
.error {
  color: var(--danger);
  margin: 8px 0 0;
  font-size: 0.92rem;
}

.empty {
  color: var(--wysh-muted);
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .topbar.navbar-wysh {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar-right {
    justify-content: space-between;
  }
  .topbar-titles .muted {
    display: none;
  }
  #app { padding-top: 16px; }
  body.login-mode { padding: 1rem; }
}
