@font-face {
  font-family: "Noto Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/NotoSans-Regular.ttf") format("truetype");
}

:root {
  --coe-bg-panel: #1a1f29;
  --coe-bg-deep: #0f1219;
  --coe-bg-elevated: #141a24;
  --coe-border: #47526b;
  --coe-border-modal: #6b618a;
  --coe-text: #f2f2fa;
  --coe-text-muted: #c7cce0;
  --coe-text-title: #f2eb9e;
  --coe-accent-gold: #f2d138;
  --coe-accent-danger: #f27373;
  --coe-accent-success: #6bcf7f;
  --coe-vignette: rgba(5, 8, 16, 0.3);
  --coe-grain-opacity: 0.12;
  --coe-font: "Noto Sans", system-ui, sans-serif;
  --coe-font-size-body: 0.9375rem;
  --coe-font-size-caption: 0.75rem;
  --coe-radius-panel: 8px;
  --coe-radius-button: 4px;
  --coe-max-width: 72rem;

  /* legacy aliases */
  --bg: var(--coe-bg-deep);
  --panel: var(--coe-bg-panel);
  --text: var(--coe-text);
  --muted: var(--coe-text-muted);
  --accent: var(--coe-accent-gold);
  --danger: var(--coe-accent-danger);
}

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

html {
  font-family: var(--coe-font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--coe-bg-deep);
  color: var(--coe-text);
}

.lk-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.lk-body .layout {
  flex: 1;
  min-height: 0;
}

.site-header__nav a {
  text-decoration: none;
}

a {
  color: var(--coe-text-title);
  text-decoration-color: var(--coe-border-modal);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--coe-accent-gold);
}

.coe-grain-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  opacity: var(--coe-grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px 180px;
  mix-blend-mode: overlay;
}

.auth-page {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-page::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, var(--coe-vignette) 100%);
}

.auth-panel {
  position: relative;
  width: 100%;
  max-width: 28rem;
  padding: 1.75rem 1.5rem 1.5rem;
  background: var(--coe-bg-elevated);
  border: 2px solid var(--coe-accent-gold);
  border-radius: var(--coe-radius-panel);
}

.auth-panel__brand {
  margin: 0 0 1.25rem;
  text-align: center;
}

.auth-panel__title {
  margin: 0;
  color: var(--coe-text-title);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.auth-panel__subtitle {
  margin: 0.15rem 0 0;
  color: var(--coe-text-muted);
  font-size: var(--coe-font-size-caption);
}

.auth-panel h1 {
  margin: 0;
  color: var(--coe-text-title);
  font-size: 1.25rem;
  font-weight: 600;
}

.auth-panel__top-link {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.auth-panel__header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.auth-panel__header h1 {
  flex: 1;
  min-width: 0;
}

.back-link {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: -0.25rem 0;
  color: var(--coe-text-title);
  text-decoration: none;
  border-radius: var(--coe-radius-button);
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--coe-accent-gold);
}

.back-link svg {
  width: 2.5rem;
  height: 2.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel {
  max-width: 40rem;
  margin: 0;
  padding: 1.5rem;
  flex: 1;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 12rem;
  padding: 1rem;
  background: var(--coe-bg-elevated);
  border-right: 1px solid var(--coe-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar a,
.sidebar button {
  color: var(--coe-text);
  text-decoration: none;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  padding: 0.5rem;
  font-family: var(--coe-font);
  font-size: var(--coe-font-size-body);
}

.sidebar a.active {
  color: var(--coe-accent-gold);
}

label {
  display: block;
  margin: 0.75rem 0;
  font-size: var(--coe-font-size-body);
}

.form-check {
  margin: 1rem 0;
}

.form-check__row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.15rem 0 0;
  accent-color: var(--coe-accent-gold);
  cursor: pointer;
}

.form-check__label {
  flex: 1;
  line-height: 1.45;
}

.form-check__label a {
  color: var(--coe-accent-gold);
}

.form-hint {
  margin: 0.5rem 0 0 1.8rem;
  font-size: var(--coe-font-size-caption);
  color: var(--coe-text-muted);
  line-height: 1.45;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 0.65rem;
  font-family: var(--coe-font);
  font-size: var(--coe-font-size-body);
  color: var(--coe-text);
  background: color-mix(in srgb, var(--coe-bg-panel) 80%, var(--coe-bg-deep));
  border: 1px solid var(--coe-border);
  border-radius: var(--coe-radius-button);
}

input:focus {
  outline: none;
  border-color: var(--coe-accent-gold);
}

input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.coe-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-family: var(--coe-font);
  font-size: var(--coe-font-size-body);
  font-weight: 600;
  color: var(--coe-text);
  background: color-mix(in srgb, var(--coe-bg-panel) 80%, var(--coe-bg-elevated));
  border: 1px solid var(--coe-border);
  border-radius: var(--coe-radius-button);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.coe-btn:hover {
  border-color: var(--coe-accent-gold);
  color: var(--coe-text-title);
}

.coe-btn--primary {
  border-color: var(--coe-accent-gold);
  border-width: 2px;
  color: var(--coe-text-title);
}

.coe-btn--primary:hover {
  background: color-mix(in srgb, var(--coe-bg-elevated) 90%, var(--coe-accent-gold) 10%);
}

.coe-btn:disabled,
.coe-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

button {
  font-family: var(--coe-font);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.form-footer {
  margin-top: 1rem;
  text-align: center;
  font-size: var(--coe-font-size-caption);
}

.error {
  color: var(--coe-accent-danger);
  margin: 0 0 0.75rem;
}

.info {
  color: var(--coe-text-muted);
  margin: 0 0 0.75rem;
}

.small {
  font-size: var(--coe-font-size-caption);
  color: var(--coe-text-muted);
}

.mt {
  margin-top: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--coe-border);
  text-align: left;
}

/* Password change (cabinet) */

.password-change {
  margin-top: 1.5rem;
}

.password-change-panel[hidden] {
  display: none;
}

.password-change-panel {
  margin-top: 1rem;
}

.field-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.field-row label {
  flex: 1;
  margin: 0;
}

.field-status {
  flex: 0 0 1.5rem;
  width: 1.5rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.field-status svg {
  width: 1.125rem;
  height: 1.125rem;
}

.field-status--ok {
  color: var(--coe-accent-success);
}

.field-status--bad {
  color: var(--coe-accent-danger);
}

.password-field {
  position: relative;
}

.password-field .password-hint {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  left: 0;
  bottom: calc(100% + 0.35rem);
  z-index: 10;
  max-width: 16rem;
  padding: 0.45rem 0.65rem;
  font-size: var(--coe-font-size-caption);
  color: var(--coe-text);
  background: var(--coe-bg-panel);
  border: 1px solid var(--coe-border-modal);
  border-radius: var(--coe-radius-button);
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
}

.password-field:hover .password-hint,
.password-field:focus-within .password-hint {
  visibility: visible;
  opacity: 1;
}

.password-change-status {
  margin: 0.5rem 0;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
  .auth-page {
    padding: 1rem max(0.75rem, env(safe-area-inset-left)) 1rem
      max(0.75rem, env(safe-area-inset-right));
    align-items: flex-start;
  }

  .auth-panel {
    padding: 1.25rem 1rem;
  }

  .auth-panel__title {
    font-size: clamp(1.15rem, 4vw, 1.25rem);
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .coe-btn {
    width: 100%;
  }

  input[type="email"],
  input[type="password"],
  input[type="text"] {
    min-height: 2.75rem;
    font-size: 1rem;
    padding: 0.65rem 0.75rem;
  }

  .form-check__row {
    min-height: 2.75rem;
    font-size: 1rem;
  }

  .form-check input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
  }

  .form-hint {
    margin-left: 0;
    font-size: 1rem;
  }

  .coe-btn {
    min-height: 2.75rem;
  }

  .back-link svg {
    width: 2rem;
    height: 2rem;
  }

  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-right: none;
    border-bottom: 1px solid var(--coe-border);
    padding: 0.75rem max(0.75rem, env(safe-area-inset-left)) 0.75rem
      max(0.75rem, env(safe-area-inset-right));
  }

  .sidebar a,
  .sidebar button {
    padding: 0.65rem 0.85rem;
    min-height: 2.75rem;
  }

  .panel {
    padding: 1rem max(0.75rem, env(safe-area-inset-left)) 1rem
      max(0.75rem, env(safe-area-inset-right));
  }

  .password-field .password-hint {
    max-width: min(16rem, calc(100vw - 2rem));
  }
}
