/* ============================================================
   CSS Variables & Base
   ============================================================ */

:root {
  --bg: #0b1220;
  --panel: #0f1a2e;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: rgba(255, 255, 255, .10);
  --brand: #60a5fa;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --sans: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(1100px 650px at 15% 10%, rgba(96, 165, 250, .18), transparent 60%), var(--bg);
}

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

a:hover {
  text-decoration: underline;
}

/* ============================================================
   Layout: Container, Topbar, Grid, Flexbox
   ============================================================ */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(11, 18, 32, .78);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.timepoint-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  margin: 6px 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(96, 165, 250, .08);
  flex-wrap: wrap;
}

.timepoint-form {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.timepoint-form .input {
  min-width: 220px;
}

.timepoint-form select.input {
  min-width: 180px;
}

.timepoint-banner {
  font-weight: 650;
  letter-spacing: .02em;
}

.is-readonly .move-btn,
.is-readonly .clear-btn {
  pointer-events: none;
  opacity: .5;
}

.is-readonly .input:disabled,
.is-readonly .textarea:disabled,
.is-readonly select:disabled,
.is-readonly button:disabled {
  opacity: .7;
  cursor: not-allowed;
}

.row,
.stack {
  display: flex;
  gap: 12px;
}

.row {
  flex-wrap: wrap;
  align-items: end;
}

.row-center {
  align-items: center;
}

.row-between {
  justify-content: space-between;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
  align-items: center;
}

.stack {
  flex-direction: column;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  align-items: start;
}

.grid-wide {
  grid-template-columns: 1.2fr .8fr;
}

@media (max-width: 980px) {

/* ============================================================
   Notices
   ============================================================ */

.notice {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  margin: 12px 0;
}

.notice.success {
  border-color: rgba(34, 197, 94, .45);
  background: rgba(34, 197, 94, .12);
  color: #bbf7d0;
}

.notice.error {
  border-color: rgba(248, 113, 113, .5);
  background: rgba(248, 113, 113, .12);
  color: #fecaca;
}

.notice.warning {
  border-color: rgba(251, 191, 36, .55);
  background: rgba(251, 191, 36, .14);
  color: #fde68a;
}

/* Flash Messages (from flask flash()) */
.flash-wrap {
  margin-bottom: 16px;
}

.flash {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  margin: 12px 0;
}

.flash.success,
.flash.info {
  border-color: rgba(34, 197, 94, .45);
  background: rgba(34, 197, 94, .12);
  color: #bbf7d0;
}

.flash.success::before {
  content: "✓ ";
  color: #22c55e;
  font-weight: bold;
}

.flash.error {
  border-color: rgba(248, 113, 113, .5);
  background: rgba(248, 113, 113, .12);
  color: #fecaca;
}

.flash.error::before {
  content: "✗ ";
  color: #dc3545;
  font-weight: bold;
}

.flash.warning {
  border-color: rgba(251, 191, 36, .55);
  background: rgba(251, 191, 36, .14);
  color: #fde68a;
}

  .grid-wide {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Typography & Headings
   ============================================================ */

.page-title {
  margin: 18px 0 12px;
  font-size: 28px;
  letter-spacing: .2px;
}

.label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 750;
}

.brand-link {
  color: inherit;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  margin-left: -10px;
}

.brand-link:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, .03);
  text-decoration: none;
}

.brand small {
  color: var(--muted);
  font-weight: 650;
}

.muted {
  color: var(--muted);
}

ul.muted li {
  margin-bottom: 8px;
}

.error {
  color: #fca5a5;
  font-weight: 700;
  margin: 10px 0;
}

/* ============================================================
   Navigation
   ============================================================ */

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav a,
.role-link {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
}

.nav a {
  color: var(--text);
}

.nav a:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, .03);
  text-decoration: none;
}

.role-link {
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.user-info .role-link {
  padding-left: 0;
}

.role-link:hover {
  opacity: 0.8;
}

.user-info {
  margin-right: 12px;
  white-space: nowrap;
}

/* User Area */
.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-direction: row-reverse;
}

/* User Dropdown */
.user-dropdown {
  position: relative;
}

.user-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.user-dropdown-toggle:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, .03);
}

.dropdown-arrow {
  transition: transform 0.2s ease;
}

.user-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 100;
}

.user-dropdown.open .user-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: block;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  transition: background 0.1s ease;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-weight: 400;
  cursor: pointer;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, .08);
  text-decoration: none;
}

.dropdown-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dropdown-item:disabled:hover {
  background: transparent;
}

.dropdown-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.dropdown-label {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Timepoint Dropdown */
.timepoint-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.timepoint-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.timepoint-dropdown-toggle:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, .03);
}

.timepoint-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 250px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 100;
}

.timepoint-dropdown.open .timepoint-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.timepoint-dates-select {
  width: 100%;
  padding: 6px 10px;
  margin: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
}

.timepoint-dates-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   Cards & Panels
   ============================================================ */

.card {
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-body {
  padding: 16px;
}

/* ============================================================
   Detail Views
   ============================================================ */

.detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
  flex: 1;
}

.value {
  font-size: 15px;
  line-height: 1.5;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ============================================================
   Form Elements
   ============================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input,
.textarea {
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
  font-family: var(--sans);
}

.input {
  min-height: 40px;
  min-width: 260px;
}

.input::placeholder,
.textarea::placeholder {
  color: rgba(229, 231, 235, .5);
}

.textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
}

.input[readonly],
.textarea[readonly] {
  background: rgba(255, 255, 255, .02);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}

.dns-textarea[readonly] {
  cursor: text;
  color: var(--text);
  opacity: 1;
}

.input.is-invalid {
  border-color: rgba(248, 113, 113, .5);
  background: rgba(248, 113, 113, .08);
}

.input.is-valid {
  border-color: rgba(34, 197, 94, .5);
  background: rgba(34, 197, 94, .08);
}

/* Select styling for dark UI */
select.input {
  appearance: none;
  background-color: rgba(255, 255, 255, .04);
  color: var(--text);
}

select.input option {
  background-color: var(--panel);
  color: var(--text);
}

select.input option:checked,
select.input option:hover {
  background-color: rgba(96, 165, 250, .25);
  color: #ffffff;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  border: 1px solid var(--border);
  background: rgba(96, 165, 250, .18);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}

.btn:hover {
  background: rgba(96, 165, 250, .26);
}

.btn.secondary {
  background: rgba(255, 255, 255, .04);
}

.nav-inline {
  display: inline;
  margin: 0;
  padding: 0;
}

/* ============================================================
   Modal
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease;
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 32, .65);
}

.modal-card {
  position: relative;
  width: min(520px, calc(100% - 40px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.modal-header {
  font-size: 16px;
  font-weight: 750;
  margin-bottom: 10px;
}

.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-close {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(255, 255, 255, .08);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.move-status {
  margin-top: 6px;
  font-size: 13px;
}

.move-status.is-occupied {
  color: #fca5a5;
}

.move-status.is-free {
  color: #86efac;
}

.move-status.is-error {
  color: #fca5a5;
}

/* ============================================================
   Tables
   ============================================================ */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-top: 14px;
}

.mapping-table {
  table-layout: fixed;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.mapping-col-from {
  width: 24%;
}

.mapping-col-arrow {
  width: 4%;
}

.mapping-col-to {
  width: 60%;
}

.mapping-col-actions {
  width: 12%;
}

.mapping-table .input {
  width: 100%;
  min-width: 0;
}

.mapping-form-row .input {
  flex: 1;
  min-width: 0;
}

.table th {
  text-align: left;
  font-weight: 750;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, .03);
}

.table tr:hover td {
  background: rgba(255, 255, 255, .02);
}

.table tr:last-child td {
  border-bottom: none;
}

.table .move-cell {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

.table .action-btn {
  padding: 6px 10px;
  line-height: 1;
  font-weight: 700;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s ease;
}

.table tr:hover .action-btn,
.table tr:focus-within .action-btn {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.icon {
  width: 14px;
  height: 14px;
  display: block;
  fill: currentColor;
}

/* ============================================================
   Lists & Relations
   ============================================================ */

.rels {
  margin: .25rem 0 0 0;
  padding-left: 1.1rem;
}

.rels li {
  margin: .15rem 0;
}

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.badge.ok {
  border-color: rgba(52, 211, 153, .35);
  background: rgba(52, 211, 153, .10);
}

.badge.warn {
  border-color: rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .10);
}

/* Compact spacing for stacked membership badges in lists/tables */
.table td > div { margin: 6px 0; }
.badge { margin-bottom: 0; }

/* ============================================================
   Auth Pages
   ============================================================ */

.auth-wrap {
  max-width: 520px;
  margin: 0 auto;
}

.auth-card {
  margin-top: 18px;
}
/* ============================================================
   Spacing Utilities
   ============================================================ */

.mt-1 {
  margin-top: 10px;
}

.mt-2 {
  margin-top: 12px;
}

.mt-3 {
  margin-top: 16px;
}

.mb-1 {
  margin-bottom: 8px;
}

.gap-sm {
  gap: 8px !important;
}

.text-center {
  text-align: center;
}

.table-col-narrow {
  width: 40px;
}

.overflow-auto {
  overflow-x: auto;
}

.text-link {
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}

.text-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.icon-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, .08);
}

.icon-btn.is-copied {
  border-color: rgba(34, 197, 94, .45);
  background: rgba(34, 197, 94, .12);
}

.dns-entry + .dns-entry {
  margin-top: 12px;
}

/* Status Messages */

.status-unsaved {
  color: #fbbf24;
  font-weight: 650;
}

.status-invalid {
  color: #fecaca;
  font-weight: 650;
}

.status-success {
  color: #bbf7d0;
  font-weight: 650;
}
