:root {
  --bg: #05070d;
  --bg-soft: #0b1220;
  --surface: #0f1728;
  --surface-2: #131f34;
  --surface-3: #172640;
  --line: #253755;
  --line-strong: #36517d;
  --text: #eaf1ff;
  --text-soft: #aec1e6;
  --primary: #4db0ff;
  --primary-strong: #76c3ff;
  --success: #47c98b;
  --danger: #ff7f7f;
  --warn: #ffd26b;
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-snappy: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  background: radial-gradient(circle at 12% 0%, #182a49 0%, var(--bg-soft) 30%, var(--bg) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  transition: color 0.15s var(--ease-out);
}

a:hover {
  color: var(--primary-strong);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.15rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.container {
  margin: 1.6rem auto 2rem;
  max-width: 1320px;
  padding: 0 1rem;
}

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

.full-width {
  grid-column: 1 / -1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(150deg, #071121 0%, #0f1e36 48%, #162a4a 100%);
  box-shadow: 0 22px 50px rgba(3, 7, 15, 0.35);
}

.topbar p,
.topbar a {
  color: var(--text-soft);
}

.topbar h1 {
  font-size: 1.35rem;
  letter-spacing: -0.005em;
  margin-bottom: 0.15rem;
}

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

.user-name {
  font-size: 0.9rem;
  color: #d6e5ff;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface) 0%, #0d1628 100%);
  padding: 1rem;
  box-shadow: 0 15px 35px rgba(3, 8, 18, 0.45);
  animation: fadeInUp 0.35s var(--ease-out) both;
}

.card h2 {
  margin-bottom: 0.35rem;
}

.card > p,
.section-help {
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.55;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface-2) 0%, #0f1a2d 100%);
  padding: 0.85rem 0.95rem;
  font-size: 0.92rem;
  line-height: 1.6;
  animation: fadeInUp 0.3s var(--ease-out) both;
}

.panel p:last-child {
  margin-bottom: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: linear-gradient(180deg, #12213a 0%, #101c30 100%);
  padding: 0.8rem;
}

.stat-label {
  color: var(--text-soft);
  font-size: 0.83rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  margin-top: 0.25rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.table-tools {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.table-note {
  margin-top: 0.65rem;
  font-size: 0.88rem;
  color: var(--text-soft);
}

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

th,
td {
  text-align: left;
  border-bottom: 1px solid #1f304d;
  padding: 0.68rem;
  vertical-align: top;
}

th {
  color: #c7d8f6;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

td {
  transition: background 0.15s var(--ease-out);
}

tr:hover td {
  background: rgba(73, 127, 214, 0.09);
}

.stacked-form {
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.34rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #dce8ff;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.56rem;
  width: 100%;
  background: #081120;
  color: var(--text);
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

input:hover,
textarea:hover,
select:hover {
  border-color: #4a6d9e;
}

input:focus,
textarea:focus,
select:focus,
button:focus,
summary:focus {
  outline: 2px solid rgba(77, 176, 255, 0.75);
  outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid #4db0ff;
  outline-offset: 2px;
}

textarea {
  resize: vertical;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox input {
  width: auto;
}

.btn,
.btn-secondary,
.btn-small {
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  transition: background 0.18s var(--ease-out), transform 0.12s var(--ease-out-snappy), box-shadow 0.18s var(--ease-out);
}

.btn {
  background: linear-gradient(145deg, #2486d8 0%, #1f6ec9 100%);
  color: #fff;
  padding: 0.58rem 0.96rem;
}

.btn:hover {
  background: linear-gradient(145deg, #2f99ea 0%, #2782df 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(36, 134, 216, 0.3);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-secondary {
  background: #142742;
  color: #dce8ff;
  border-color: #345176;
  padding: 0.47rem 0.78rem;
}

.btn-secondary:hover {
  background: #1b3254;
  border-color: #4a6d9e;
}

.btn-secondary:active {
  background: #142742;
}

.btn-small {
  background: #132742;
  color: #dce9ff;
  border-color: #2a456f;
  padding: 0.38rem 0.62rem;
}

.btn-small:hover {
  background: #1b3356;
  border-color: #3d6290;
}

.btn-small:active {
  background: #132742;
}

.pill {
  border-radius: 999px;
  border: 1px solid #385783;
  padding: 0.13rem 0.5rem;
  background: #13233d;
  font-size: 0.82rem;
  color: #d5e7ff;
}

.pill--operational::before,
.pill--resolved::before,
.pill--degraded::before,
.pill--downtime::before,
.pill--maintenance::before {
  display: inline-block;
  margin-right: 0.3em;
  font-size: 0.85em;
  line-height: 1;
}

.pill--operational,
.pill--resolved {
  border-color: var(--success);
  color: var(--success);
  background: rgba(71, 201, 139, 0.12);
}

.pill--operational::before,
.pill--resolved::before {
  content: "\2713";
}

.pill--degraded {
  border-color: var(--warn);
  color: var(--warn);
  background: rgba(255, 210, 107, 0.12);
}

.pill--degraded::before {
  content: "\25B2";
  font-size: 0.7em;
}

.pill--downtime {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(255, 127, 127, 0.12);
}

.pill--downtime::before {
  content: "\2716";
}

.pill--maintenance {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(77, 176, 255, 0.12);
}

.pill--maintenance::before {
  content: "\2699";
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert {
  padding: 0.68rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1px solid;
  animation: slideInDown 0.3s var(--ease-out);
}

.alert.success {
  color: #dcffe9;
  border-color: #2f8e66;
  background: rgba(34, 110, 79, 0.45);
}

.alert.error {
  color: #ffe5e5;
  border-color: #a74646;
  background: rgba(112, 36, 36, 0.45);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: radial-gradient(ellipse at 50% 40%, rgba(36, 134, 216, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 12% 0%, #182a49 0%, var(--bg-soft) 30%, var(--bg) 100%);
}

.login-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-top: 2px solid var(--primary);
  border-radius: 14px;
  background: linear-gradient(180deg, #101b2f 0%, #0b1424 100%);
  padding: 1.5rem;
  box-shadow: 0 20px 45px rgba(4, 10, 20, 0.52);
  animation: fadeInUp 0.4s var(--ease-out) both;
  text-align: center;
}

.login-card h1 {
  font-size: 1.6rem;
  letter-spacing: -0.015em;
}

.login-card p {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.login-card .stacked-form {
  text-align: left;
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.login-status-dot {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: var(--surface);
  position: relative;
}

.login-status-dot::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2.5s var(--ease-out) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.85); }
}

.subtle-link {
  font-size: 0.95rem;
}

.counter-hint {
  display: inline-block;
  margin-left: 0.2rem;
  color: var(--warn);
  font-weight: 700;
}

.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  border: 1px solid #5678a8;
  color: #b4ccf5;
  font-size: 0.72rem;
  margin-left: 0.3rem;
  cursor: help;
  position: relative;
  transition: border-color 0.15s var(--ease-out), color 0.15s var(--ease-out);
}

.tip:hover,
.tip:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
}

.tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  transform: translateX(-50%);
  min-width: 220px;
  max-width: 300px;
  padding: 0.45rem 0.52rem;
  border-radius: 8px;
  border: 1px solid #425f8a;
  background: #0a1324;
  color: #e5efff;
  font-size: 0.78rem;
  line-height: 1.35;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.18s var(--ease-out), visibility 0.18s var(--ease-out), transform 0.18s var(--ease-out);
  transform: translateX(-50%) translateY(4px);
}

.tip:hover::after,
.tip:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.resource-details {
  margin-top: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d172a;
}

.resource-details > summary {
  cursor: pointer;
  padding: 0.68rem 0.78rem;
  list-style: none;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.15s var(--ease-out);
}

.resource-details > summary:hover {
  color: var(--primary-strong);
}

.resource-details[open] > summary {
  color: var(--primary);
}

.resource-details > summary::-webkit-details-marker {
  display: none;
}

.resource-count {
  font-size: 0.85rem;
  color: #a8c2eb;
  font-weight: 600;
}

.resource-picker {
  padding: 0.68rem 0.78rem 0.82rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.68rem;
}

.resource-toolbar {
  display: grid;
  gap: 0.56rem;
}

.resource-search {
  width: 100%;
}

.resource-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.btn-chip {
  border: 1px solid #456187;
  background: #10233d;
  color: #d6e7ff;
  border-radius: 999px;
  padding: 0.3rem 0.66rem;
  font-size: 0.83rem;
  cursor: pointer;
  transition: background 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}

.btn-chip:hover {
  background: #173154;
  border-color: #5a7ea8;
}

.resource-meta {
  font-size: 0.82rem;
  color: var(--text-soft);
}

.resource-list {
  border: 1px solid #274063;
  border-radius: 9px;
  max-height: 22rem;
  overflow: auto;
  background: #091425;
}

.resource-row {
  padding: 0.55rem;
  border-bottom: 1px solid #1c2f4d;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13rem;
  gap: 0.44rem;
  align-items: center;
}

.resource-row:last-child {
  border-bottom: 0;
}

.resource-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.table-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 24px;
  background: linear-gradient(to left, rgba(13, 22, 40, 0.9), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s var(--ease-out);
}

.table-wrap--scrollable::after {
  opacity: 1;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-soft);
  font-weight: 400;
}

.char-counter {
  font-size: 0.8rem;
  color: var(--text-soft);
  text-align: right;
  display: block;
}

.btn:disabled,
.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

.btn-submitting::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  margin-right: 0.4em;
  vertical-align: -0.1em;
  animation: spin 0.6s linear infinite;
}

.truncate-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 10, 0.8);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s var(--ease-out);
}

.confirm-dialog {
  width: min(480px, calc(100% - 2rem));
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: linear-gradient(180deg, #101b2f 0%, #0b1424 100%);
  padding: 1.5rem;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  animation: fadeInUp 0.25s var(--ease-out-snappy);
}

.confirm-dialog h3 {
  margin: 0 0 0.5rem;
  color: var(--text);
}

.confirm-dialog p {
  color: var(--text-soft);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.confirm-dialog .confirm-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #081120;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  max-height: 10rem;
  overflow-y: auto;
}

.confirm-dialog .confirm-summary dt {
  color: var(--text-soft);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.5rem;
}

.confirm-dialog .confirm-summary dt:first-child {
  margin-top: 0;
}

.confirm-dialog .confirm-summary dd {
  margin: 0.15rem 0 0;
  color: var(--text);
  word-break: break-word;
}

.confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.confirm-warn {
  color: var(--warn);
  font-weight: 600;
  font-size: 0.88rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
  }

  .resource-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  th,
  td {
    font-size: 0.9rem;
    padding: 0.58rem;
  }

  .btn,
  .btn-secondary,
  .btn-small {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .truncate-cell {
    max-width: 160px;
  }

  .confirm-dialog {
    padding: 1.2rem;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 0.95rem;
  }

  .container {
    padding: 0 0.75rem;
    margin-top: 1rem;
  }

  .topbar {
    padding: 0.85rem 0.75rem;
  }

  .topbar h1 {
    font-size: 1.2rem;
  }

  .card {
    padding: 0.85rem;
    border-radius: 10px;
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .stat {
    padding: 0.6rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .login-card {
    padding: 1.2rem;
  }

  .resource-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .confirm-actions {
    flex-direction: column-reverse;
  }

  .confirm-actions .btn,
  .confirm-actions .btn-secondary {
    width: 100%;
  }
}
