:root {
  --primary: #1363df;
  --primary-dark: #0d4cac;
  --accent: #47cacc;
  --danger: #d64545;
  --success: #2f9b59;
  --background: #f5f7fb;
  --text-main: #1d2433;
  --text-muted: #5a6475;
  --card-shadow: 0 24px 50px -30px rgba(13, 36, 89, 0.4);
  --border-radius: 18px;
  font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(19, 99, 223, 0.18), transparent 55%),
    radial-gradient(circle at bottom right, rgba(71, 202, 204, 0.18), transparent 45%),
    var(--background);
  color: var(--text-main);
}

body,
input,
select,
button {
  font-family: inherit;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(1.5rem, 2vw + 1rem, 3rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

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

.branding__logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  font-size: 1.2rem;
  box-shadow: 0 12px 25px -15px rgba(19, 99, 223, 0.8);
}

.branding__title {
  font-weight: 600;
  font-size: clamp(1.35rem, 1.1vw + 1.1rem, 1.75rem);
}

.mill-tag {
  background: rgba(19, 99, 223, 0.08);
  border: 1px solid rgba(19, 99, 223, 0.18);
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 200px;
}

.mill-tag__label {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.mill-tag__value {
  font-weight: 600;
  font-size: clamp(1rem, 0.7vw + 0.85rem, 1.25rem);
}

.card {
  background: #fff;
  padding: clamp(1.5rem, 2vw + 1rem, 3rem);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
}

.card__header {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.75rem;
}

.card__title {
  margin: 0;
  font-size: clamp(1.6rem, 1.5vw + 1.2rem, 2.1rem);
}

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

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.status-chip {
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(13, 76, 172, 0.08);
  border: 1px solid rgba(13, 76, 172, 0.18);
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.status-chip__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(47, 155, 89, 0.15);
}

.status-chip--offline {
  background: rgba(214, 69, 69, 0.08);
  border-color: rgba(214, 69, 69, 0.28);
  color: var(--danger);
}

.status-chip--offline .status-chip__dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(214, 69, 69, 0.15);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem 1.5rem;
}

.form-control {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-control label {
  font-weight: 600;
}

.form-control input,
.form-control select {
  border: 1px solid rgba(19, 35, 53, 0.2);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: #fdfdfd;
  color: var(--text-main);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control input:focus,
.form-control select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(19, 99, 223, 0.15);
}

.form-control input::placeholder {
  color: rgba(29, 36, 51, 0.35);
}

.actions {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.primary-button {
  align-self: flex-start;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  border-radius: 14px;
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0.9rem 2.4rem;
  cursor: pointer;
  box-shadow: 0 18px 35px -18px rgba(19, 99, 223, 0.8);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.primary-button:hover,
.primary-button:focus {
  transform: translateY(-1px);
  box-shadow: 0 20px 40px -18px rgba(19, 99, 223, 0.85);
}

.primary-button:active {
  transform: translateY(0);
  box-shadow: 0 14px 28px -18px rgba(19, 99, 223, 0.7);
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  padding: 0.85rem 1.4rem;
  border-radius: 14px;
  background: #1d2433;
  color: #fff;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1200;
}

.toast[data-visible="true"] {
  opacity: 0.98;
  transform: translate(-50%, -8px);
}

.toast--error {
  background: var(--danger);
}

.toast--success {
  background: var(--success);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 14, 39, 0.38);
  display: grid;
  place-items: center;
  z-index: 1100;
}

.overlay[hidden] {
  display: none;
}

.loading-panel {
  background: #fff;
  padding: 1.4rem 2rem;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(19, 99, 223, 0.18);
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 14, 39, 0.45);
  display: grid;
  place-items: center;
  z-index: 1200;
}

.modal[hidden] {
  display: none;
}

.modal__content {
  background: #fff;
  border-radius: 18px;
  padding: 2.2rem 2.6rem;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.modal__title {
  margin: 0;
  font-size: 1.6rem;
}

.modal__actions {
  display: flex;
  justify-content: center;
}

.secondary-button {
  background: none;
  border: 2px solid var(--primary);
  border-radius: 12px;
  color: var(--primary);
  font-weight: 600;
  padding: 0.65rem 1.8rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.secondary-button:hover,
.secondary-button:focus {
  background: var(--primary);
  color: #fff;
}

.page__footer {
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.pending-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.pending-counter strong {
  font-weight: 700;
}

.landing {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(2rem, 3vw + 1.5rem, 4rem);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.landing__intro {
  background: #fff;
  padding: clamp(1.8rem, 2vw + 1.4rem, 2.6rem);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.mill-card {
  background: #fff;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mill-card:hover,
.mill-card:focus-within {
  transform: translateY(-3px);
  box-shadow: 0 28px 45px -35px rgba(13, 36, 89, 0.55);
}

.mill-card__title {
  margin: 0;
  font-size: 1.2rem;
}

.mill-card__link {
  align-self: flex-start;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 12px;
  color: #fff;
  padding: 0.6rem 1.4rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

@media (max-width: 900px) {
  .page {
    padding: clamp(1.4rem, 2.5vw + 1rem, 2.4rem);
    gap: 1.25rem;
  }

  .page__header {
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
  }

  .branding {
    justify-content: flex-start;
  }

  .mill-tag {
    align-self: stretch;
  }

  .card {
    padding: clamp(1.6rem, 3vw + 1.1rem, 2.5rem);
  }

  .modal__content {
    width: min(90vw, 420px);
  }
}

@media (max-width: 768px) {
  .status-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .status-chip {
    width: 100%;
    justify-content: space-between;
  }

  .form-grid {
    gap: 1rem;
  }

  .card__header {
    gap: 0.5rem;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 1.25rem;
  }

  .mill-tag {
    width: 100%;
    align-items: center;
    text-align: center;
  }

  .actions {
    align-items: stretch;
  }

  .primary-button {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .branding {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .branding__logo {
    width: 46px;
    height: 46px;
  }

  .helper-text {
    font-size: 0.8rem;
  }

  .modal__content {
    padding: 1.6rem 1.8rem;
  }
}

.auth-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1000;
}

.auth-gate--active {
  opacity: 1;
  pointer-events: all;
}

.auth-gate__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.65);
  backdrop-filter: blur(4px);
}

.auth-gate__dialog {
  position: relative;
  width: min(90vw, 420px);
  background: #fff;
  padding: clamp(1.75rem, 2vw + 1.2rem, 2.5rem);
  border-radius: var(--border-radius);
  box-shadow: 0 28px 60px -24px rgba(10, 27, 71, 0.45);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  z-index: 1;
}

.auth-gate__header {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.auth-gate__logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.auth-gate__title {
  margin: 0;
  font-size: 1.4rem;
}

.auth-gate__subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.auth-gate__form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.auth-gate__label {
  font-weight: 600;
}

.auth-gate__input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(19, 99, 223, 0.25);
  padding: 0.85rem 1rem;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-gate__input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(19, 99, 223, 0.2);
}

.auth-gate__input[aria-invalid='true'] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.18);
}

.auth-gate__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.auth-gate__error {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.9rem;
}

.auth-gate__submit {
  padding: 0.9rem 1.1rem;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.auth-gate__submit:hover,
.auth-gate__submit:focus {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.auth-gate__submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
