:root {
  color-scheme: light dark;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
  --bg-primary: #05070f;
  --bg-secondary: #0c101c;
  --bg-elevated: rgba(12, 16, 28, 0.82);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-strong: rgba(255, 255, 255, 0.18);
  --text-primary: #f5f7fb;
  --text-muted: #b8c0d8;
  --accent: #ff7b54;
  --accent-secondary: #ffb74a;
  --accent-gradient: linear-gradient(135deg, #ff7b54 0%, #ffb74a 100%);
  --accent-focus: rgba(255, 123, 84, 0.35);
  --accent-shadow: 0 22px 44px -28px rgba(255, 123, 84, 0.9);
  --card-shadow: 0 40px 80px -48px rgba(5, 7, 15, 0.85);
}

body {
  margin: 0;
  background: radial-gradient(circle at 20% -10%, rgba(255, 123, 84, 0.22), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(67, 97, 238, 0.2), transparent 45%), var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body.lang-ar {
  font-family: 'Cairo', 'Inter', 'Tajawal', system-ui, sans-serif;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background: radial-gradient(circle at 20% -10%, rgba(255, 123, 84, 0.22), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(67, 97, 238, 0.2), transparent 45%), var(--bg-primary);
}

.auth-card {
  width: min(440px, 100%);
  padding: 2.5rem 2.25rem;
  border-radius: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  backdrop-filter: blur(16px);
}

body.lang-ar .auth-card {
  direction: rtl;
  text-align: right;
}

body.lang-en .auth-card {
  direction: ltr;
  text-align: left;
}

.auth-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.auth-card__brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: inherit;
  text-decoration: none;
}

.auth-card__logo-symbol {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #1a0a07;
  font-size: 1.25rem;
  box-shadow: 0 12px 26px -18px rgba(255, 123, 84, 0.9);
}

.auth-card__logo-text {
  font-size: 1.1rem;
}

.auth-card__lang-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  padding: 0.35rem;
  border: 1px solid var(--glass-border);
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.lang-btn.active {
  background: var(--accent-gradient);
  color: #1a0a07;
}

.auth-card__header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-card__title {
  font-size: clamp(1.75rem, 2vw + 1rem, 2.35rem);
  margin: 0;
}

.auth-card__subtitle {
  margin: 0;
  color: var(--text-muted);
}

.auth-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  gap: 0.25rem;
}

.auth-toggle__button {
  border: none;
  background: transparent;
  color: inherit;
  padding: 0.65rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.auth-toggle__button--active {
  background: var(--accent-gradient);
  color: #1a0a07;
  box-shadow: var(--accent-shadow);
}

.auth-card__message {
  padding: 0.75rem 1rem;
  border-radius: 0.85rem;
  font-size: 0.95rem;
  border: 1px solid transparent;
}

.auth-card__message--success {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  color: #c6f6d5;
}

.auth-card__message--error {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fecaca;
}

.auth-panel {
  display: block;
}

.auth-panel--hidden {
  display: none;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Dashboard */

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dashboard__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem;
  border-radius: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  box-shadow: var(--card-shadow);
}

.dashboard__title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
}

.dashboard__subtitle {
  margin: 0;
  color: var(--text-muted);
  max-width: 38ch;
}

.dashboard__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dashboard__connect,
.dashboard__refresh {
  border: 1px solid var(--glass-border-strong);
  border-radius: 999px;
  padding: 0.55rem 1.4rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.dashboard__refresh {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.dashboard__refresh:hover,
.dashboard__refresh:focus-visible {
  background: rgba(255, 255, 255, 0.12);
}

.dashboard__connect {
  background: var(--accent-gradient);
  color: #1a0a07;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--accent-shadow);
}

.dashboard__connect:hover,
.dashboard__connect:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 26px 50px -30px rgba(255, 123, 84, 0.9);
}

.dashboard__connect[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.dashboard__status {
  display: grid;
  gap: 0.75rem;
}

.dashboard__message {
  padding: 0.85rem 1.1rem;
  border-radius: 0.85rem;
  border-left: 4px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.95rem;
}

.dashboard__message[data-status='success'] {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.65);
  color: #dcfce7;
}

.dashboard__message[data-status='error'] {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.7);
  color: #fecaca;
}

.dashboard__message[data-status='info'] {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.55);
  color: #bfdbfe;
}

.dashboard__loading {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.dashboard__empty {
  padding: 2rem;
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  text-align: center;
  display: grid;
  gap: 0.5rem;
}

.dashboard__empty-title {
  margin: 0;
  font-size: 1.3rem;
}

.dashboard__empty-copy {
  margin: 0;
  color: var(--text-muted);
}

.dashboard__accounts {
  display: block;
}

.dashboard__account-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.25rem;
}

.dashboard-account {
  background: rgba(12, 16, 28, 0.9);
  border: 1px solid var(--glass-border);
  border-radius: 1.25rem;
  padding: 1.5rem;
  display: grid;
  gap: 1rem;
  box-shadow: var(--card-shadow);
}

.dashboard-account__header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dashboard-account__name {
  margin: 0;
  font-size: 1.25rem;
}

.dashboard-account__meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.dashboard-account__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.dashboard-account__sync {
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1.3rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.dashboard-account__sync:hover,
.dashboard-account__sync:focus-visible {
  background: rgba(255, 255, 255, 0.25);
}

.dashboard-account__sync:disabled {
  opacity: 0.6;
  cursor: progress;
}

.dashboard-account__timestamp {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dashboard-account__metrics {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin: 0;
}

.dashboard-account__metric {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dashboard-account__metric dt {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.dashboard-account__metric dd {
  margin: 0.35rem 0 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

@media (max-width: 640px) {
  .dashboard__header {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard__actions {
    width: 100%;
    justify-content: stretch;
  }

  .dashboard__connect,
  .dashboard__refresh {
    width: 100%;
    justify-content: center;
  }

  .dashboard-account__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-account__sync {
    width: 100%;
  }
}

.auth-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.auth-form__field > label {
  color: var(--text-muted);
}

.auth-form__field > input {
  padding: 0.75rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 11, 19, 0.65);
  color: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-form__field > input:focus-visible {
  border-color: rgba(255, 123, 84, 0.6);
  box-shadow: 0 0 0 3px var(--accent-focus);
  outline: none;
}

body.lang-ar .auth-form__field > input {
  text-align: right;
}

body.lang-en .auth-form__field > input {
  text-align: left;
}

.auth-form__submit {
  margin-top: 0.5rem;
  padding: 0.85rem;
  border-radius: 999px;
  border: none;
  background: var(--accent-gradient);
  color: #1a0a07;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--accent-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.auth-form__submit:disabled {
  cursor: wait;
  filter: grayscale(0.25);
  opacity: 0.75;
}

.auth-form__submit:hover:not(:disabled),
.auth-form__submit:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 26px 50px -30px rgba(255, 123, 84, 0.9);
}

.auth-card__footer {
  display: flex;
  justify-content: center;
}

.auth-card__link {
  color: var(--accent-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.auth-card__link:hover,
.auth-card__link:focus-visible {
  color: var(--accent);
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem;
}

.app-shell__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  margin-bottom: 1.5rem;
}

.app-shell__login-button {
  padding: 0.55rem 1.25rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.85), rgba(129, 140, 248, 0.85));
  color: #f8fafc;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 12px 20px -14px rgba(59, 130, 246, 0.9);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.app-shell__login-button:hover,
.app-shell__login-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px -18px rgba(59, 130, 246, 0.9);
  filter: brightness(1.05);
}

.app-shell__nav {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.app-shell__nav-button {
  flex: 1;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(30, 41, 59, 0.6);
  color: inherit;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.app-shell__nav-button:hover,
.app-shell__nav-button:focus-visible {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
}

.app-shell__nav-button--active {
  background: rgba(59, 130, 246, 0.3);
  border-color: rgba(59, 130, 246, 0.8);
}

.scheduler,
.analytics {
  background: rgba(30, 41, 59, 0.8);
  padding: 1.5rem;
  border-radius: 0.75rem;
  box-shadow: 0 20px 25px -15px rgba(15, 23, 42, 0.9);
}

.scheduler__form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.scheduler__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.scheduler__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.scheduler__field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.scheduler__field > input,
.scheduler__field > textarea {
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.8);
  color: inherit;
}

.scheduler__submit {
  align-self: flex-start;
  padding: 0.6rem 1.5rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(139, 92, 246, 0.9));
  color: #f8fafc;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 15px 30px -20px rgba(59, 130, 246, 0.9);
}

.scheduler__clear {
  padding: 0.55rem 1.25rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
  color: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.scheduler__clear:hover,
.scheduler__clear:focus-visible {
  border-color: rgba(59, 130, 246, 0.6);
  background: rgba(59, 130, 246, 0.1);
}

.scheduler__status {
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.9);
}

.analytics__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.analytics__card {
  padding: 1rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.analytics__title {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.95);
}

.analytics__metric {
  font-size: 1.75rem;
  font-weight: 700;
  color: #f8fafc;
}

.analytics__unit {
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(148, 163, 184, 0.9);
}

.analytics__delta {
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(148, 163, 184, 0.9);
}

.analytics__delta--positive {
  color: rgba(74, 222, 128, 0.85);
}

.analytics__delta--negative {
  color: rgba(248, 113, 113, 0.9);
}

.analytics__hint,
.analytics__card .hint {
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.9);
}

.analytics__meta {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: rgba(148, 163, 184, 0.9);
}

.analytics__meta[data-status='error'] {
  color: rgba(248, 113, 113, 0.92);
}

.analytics__meta[data-status='success'] {
  color: rgba(74, 222, 128, 0.92);
}
