:root {
  color-scheme: dark;
  --bg: #090c0e;
  --panel: rgba(22, 28, 30, 0.75);
  --panel-2: rgba(32, 41, 45, 0.65);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f1f6f8;
  --muted: #9bb1b7;
  
  /* HSL Tailored Theme Colors */
  --accent: #10b981; /* Vibrant Emerald Green */
  --accent-rgb: 16, 185, 129;
  --accent-2: #f59e0b; /* Warm Amber */
  --danger: #ef4444; /* Rose/Crimson */
  --indigo: #6366f1; /* Deep Indigo */
  
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: -0.01em;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Headings with Outfit font family */
h1, h2, h3 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  margin-top: 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.2rem);
  margin-bottom: 0;
  background: linear-gradient(135deg, #ffffff 0%, #a3b8be 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 {
  font-size: 1.15rem;
  margin-bottom: 0;
  color: #ffffff;
}

h3 {
  font-size: 1.05rem;
  margin-bottom: 4px;
  color: #ffffff;
}

p {
  margin-top: 0;
}

/* Glassmorphism Container Design System */
.surface,
.metric,
.server-card {
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease, border-color 0.25s ease;
}

.surface:hover,
.server-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  border-color: rgba(16, 185, 129, 0.25);
}

.expired-alert {
  border-color: rgba(239, 68, 68, 0.6) !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.1) !important;
}

.warning-alert {
  border-color: rgba(245, 158, 11, 0.6) !important;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.1) !important;
}

.surface {
  padding: 22px;
}

/* Inputs & Form Controls */
label {
  color: var(--muted);
  display: grid;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 12, 14, 0.8);
  color: var(--text);
  padding: 12px 14px;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

textarea {
  resize: vertical;
}

/* Premium Buttons & Micro-Animations */
button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #032b1d;
  cursor: pointer;
  font-weight: 700;
  padding: 0 20px;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

button:active {
  transform: scale(0.98);
}

button.quiet-button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: none;
}

button.quiet-button:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

/* Tab Navigation System */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 5px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs button {
  flex: 0 0 auto;
  min-width: 110px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: none;
  font-weight: 600;
}

.tabs button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.tabs button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.1);
}

.tab-view {
  display: grid;
  gap: 20px;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* PENTING: Pastikan hidden attribute tidak dioverride oleh display:grid dll */
.tab-view[hidden],
[hidden] {
  display: none !important;
}

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

/* Login View Styling - Fixed fullscreen overlay */
.login-shell {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 30%, rgba(16, 185, 129, 0.10) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    var(--bg);
  animation: pageIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-shell[hidden] {
  display: none;
}

.login-panel {
  background: var(--panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 20px;
  max-width: 420px;
  padding: clamp(24px, 6vw, 40px);
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: cardIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardIn {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.login-panel h1 {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
}

.form-error {
  color: var(--danger);
  margin: 0;
  min-height: 1.2em;
  font-size: 0.88rem;
  font-weight: 500;
}

/* App Shell Wrapper */
.app-shell {
  margin: 0 auto;
  max-width: 1280px;
  padding: 24px;
  animation: pageIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Header & Headers Layouts */
.topbar,
.section-head,
.detail-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

/* Tab page header dengan judul dan deskripsi */
.tab-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.tab-header h2 {
  margin-bottom: 4px;
}

.tab-header .muted {
  margin: 0;
  font-size: 0.88rem;
}

.topbar {
  padding: 10px 0 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--accent);
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.muted,
.empty,
.server-card p {
  color: var(--muted);
  font-size: 0.92rem;
}

/* Metrics Dashboard Grid */
.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.metric {
  display: grid;
  gap: 6px;
  min-height: 98px;
  padding: 18px;
  box-shadow: none;
}

.metric span,
dt,
.count {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric strong {
  font-size: 1.9rem;
  font-weight: 800;
  color: #ffffff;
}

/* Grids & Layout Splits */
.split-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
}

.inline-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid button {
  justify-self: start;
  margin-top: 8px;
}

.span-two {
  grid-column: span 2;
}

/* Lists and Details Rows */
.stack-list,
.compact-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.list-row,
.compact-row {
  background: var(--panel-2);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 4px;
  padding: 14px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.list-row:hover,
.compact-row:hover {
  border-color: rgba(16, 185, 129, 0.15);
  transform: translateX(2px);
}

.list-row strong,
.compact-row strong {
  color: #ffffff;
}

.list-row span,
.compact-row span {
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

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

/* Server Cards Grid */
.server-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
}

.server-card {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 20px;
}

.server-card dl,
.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

dl div {
  min-width: 0;
}

dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 600;
  color: #ffffff;
  font-size: 0.95rem;
}

.action-row,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.action-row button {
  min-height: 38px;
  padding: 0 16px;
  font-size: 0.88rem;
}

/* Custom Styled State Pills (HSL-Based Colors) */
.state-pill,
.count {
  background: rgba(33, 44, 49, 0.75);
  border: 1px solid var(--line);
  border-radius: 999px;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 6px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.state-pill.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.state-pill.suspended,
.state-pill.expired {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.state-pill.panel_only {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.state-pill.imported_unmanaged {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.35);
  color: #818cf8;
}

/* Dialog & Details Modals */
dialog {
  background: rgba(22, 28, 30, 0.98);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  max-height: calc(100vh - 40px);
  max-width: 760px;
  overflow: auto;
  padding: 24px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6);
  width: min(760px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.detail-grid {
  background: var(--panel-2);
  border-radius: 10px;
  margin: 16px 0;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.notice {
  border-left: 3px solid var(--accent-2);
  background: rgba(245, 158, 11, 0.04);
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 0.88rem;
  line-height: 1.4;
}

.detail-form {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 20px;
}

code {
  background: #090c0e;
  border-radius: 6px;
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 5px 8px;
  font-family: monospace;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  color: #fca5a5; /* Soft light red password text */
}

/* Toast Message Notifications */
.toast {
  background: #1e293b;
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  font-weight: 600;
  border-radius: 8px;
  bottom: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  left: 50%;
  max-width: min(560px, calc(100vw - 24px));
  padding: 14px 20px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.92rem;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translate(-50%, 12px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* Adaptive Layouts & Media Queries */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }
  .app-shell {
    padding: 16px;
  }
  .surface {
    padding: 16px;
  }
  .split-grid, .form-grid, .detail-grid, .server-grid {
    grid-template-columns: 1fr;
  }
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
  .server-card {
    padding: 12px;
    gap: 8px;
  }
  .server-card dl {
    gap: 6px 12px;
  }
  .server-card h3 {
    font-size: 0.95rem;
  }
  .server-card p {
    font-size: 0.75rem;
  }
  .server-card dt {
    font-size: 0.65rem;
  }
  .server-card dd {
    font-size: 0.8rem;
    margin-top: 2px;
  }
  .action-row {
    gap: 8px;
    margin-top: 0;
  }
  .action-row button {
    min-height: 32px;
    padding: 0 12px;
    font-size: 0.75rem;
  }
  .inline-form {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
  .topbar {
    align-items: flex-start;
  }
  .topbar button {
    align-self: flex-start;
    padding: 6px 12px;
    font-size: 0.8rem;
  }
  .tabs {
    flex-wrap: wrap;
    justify-content: center;
    border-bottom: none;
  }
  .tabs button {
    flex: 1 1 calc(33% - 12px);
    text-align: center;
    padding: 10px 8px;
    font-size: 0.85rem;
  }
  .form-tabs {
    flex-direction: column;
  }
  .span-two {
    grid-column: span 1;
  }
  .count {
    white-space: nowrap;
  }
  .server-card .section-head,
  .detail-head {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }
}
