:root {
  --urra-primary: #e25822;
  --urra-secondary: #ff4500;
  --surface-card: #ffffff;
  --surface-soft: #fff6f1;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --ok: #16a34a;
  --bad: #dc2626;
  --ring: rgba(226, 88, 34, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

body > :not(footer) { flex: 1 0 auto; }
footer { flex-shrink: 0; margin-top: auto; }

.panel-bg,
.auth-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(145deg, rgba(226, 88, 34, 0.08), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.auth-card,
.card {
  background: var(--surface-card);
  border: 1px solid rgba(226, 88, 34, 0.22);
  border-radius: 16px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
}

.auth-card {
  padding: 2rem;
  position: relative;
  animation: float-in 0.45s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brand-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

h1,
h2 {
  margin: 0;
}

.auth-subtitle {
  margin-top: 0.35rem;
  margin-bottom: 1.1rem;
  color: var(--text-muted);
}

.auth-form {
  display: grid;
  gap: 0.65rem;
  width: 100%;
}

.login-btn {
  width: 100%;
  text-align: center;
  display: block !important;
}

footer {
  background: #f3f4f6;
  padding: 1rem 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

label {
  font-size: 0.9rem;
  color: #9a3412;
}

input {
  border: 1px solid rgba(226, 88, 34, 0.35);
  border-radius: 10px;
  padding: 0.72rem 0.8rem;
  background: #ffffff;
  color: var(--text-main);
  outline: none;
}

input:focus {
  border-color: var(--urra-secondary);
  box-shadow: 0 0 0 3px var(--ring);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem 0.5rem;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-wrap p {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
}

.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0 1.25rem 1.25rem;
}

.card {
  padding: 1rem;
  animation: float-in 0.35s ease;
}

.top-status-card {
  padding: 1.15rem;
}

.control-row {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}

.status-group,
.uptime-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.8rem;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid rgba(226, 88, 34, 0.18);
}

.status-group {
  min-width: 260px;
  flex: 1;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-start !important;
}

.uptime-group {
  min-width: 170px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid rgba(226, 88, 34, 0.2);
}

.meta-line {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  color: var(--text-main);
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid rgba(226, 88, 34, 0.2);
}

.meta-line strong {
  color: #111827;
  font-weight: 700;
}

.label {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.status-badge {
  width: fit-content;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
}

.status-badge.online {
  color: #0b7a35;
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.45);
}

.status-badge.offline {
  color: #9f1239;
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.4);
}

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

.meter {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid rgba(226, 88, 34, 0.18);
}

.meter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.meter-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  color: var(--text-main);
}

.meter-value {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Track is a neutral, hue-agnostic gray on purpose: the fill's color shifts
   between the good/warning/critical steps below, so the empty portion can't
   be "a lighter step of the fill's own ramp" the way a single-hue meter
   would - a fixed neutral reads correctly against all three. */
.meter-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: #e7e2de;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  min-width: 3px;
  border-radius: 999px;
  width: 0%;
  background: #16a34a;
  transition: width 0.5s ease, background-color 0.3s ease;
}

.meter-fill.level-warning { background: #d97706; }
.meter-fill.level-critical { background: #dc2626; }
.meter-fill.level-idle { background: #b0b7c3; }

.meter-status {
  align-self: flex-start;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
}

.meter-status.level-good { color: #0b7a35; background: rgba(34, 197, 94, 0.16); }
.meter-status.level-warning { color: #92400e; background: rgba(217, 119, 6, 0.16); }
.meter-status.level-critical { color: #9f1239; background: rgba(220, 38, 38, 0.14); }
.meter-status.level-idle { color: var(--text-muted); background: rgba(107, 114, 128, 0.12); }

.uptime-value {
  font-size: 1.35rem;
  color: #9a3412;
}

.btn {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(120deg, var(--urra-primary), var(--urra-secondary));
  color: #ffffff;
  font-weight: 700;
  padding: 0.62rem 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(226, 88, 34, 0.5);
  color: #9a3412;
}

.btn.danger {
  background: linear-gradient(120deg, #bf2b2b, #eb4d4d);
}

.btn-start {
  background: linear-gradient(120deg, #16a34a, #22c55e);
}

.btn-restart {
  background: linear-gradient(120deg, #eab308, #f59e0b);
  color: #111827;
}

.btn-stop {
  background: linear-gradient(120deg, #dc2626, #ef4444);
}

.action-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.logs-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.command-row {
  display: flex;
  align-items: center;
}

.command-form {
  display: flex;
  width: 100%;
  gap: 0.5rem;
}

.command-form input {
  flex: 1;
}

.output-box,
.logs-box {
  border-radius: 10px;
  padding: 0.85rem;
  background: #fff8f4;
  border: 1px solid rgba(226, 88, 34, 0.25);
  min-height: 120px;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  color: #7c2d12;
}

.logs-box {
  min-height: 340px;
  max-height: 50vh;
  line-height: 1.4;
  background: #000000;
  color: #ffffff;
  border: 1px solid #2b2b2b;
}

.logs-box::-webkit-scrollbar {
  width: 12px;
}

.logs-box::-webkit-scrollbar-track {
  background: #111111;
  border-radius: 10px;
}

.logs-box::-webkit-scrollbar-thumb {
  background: #f3f4f6;
  border-radius: 10px;
  border: 2px solid #111111;
}

.logs-box {
  scrollbar-color: #f3f4f6 #111111;
  scrollbar-width: thin;
}

.logs-tools {
  display: flex;
  justify-content: flex-end;
}

.alert {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
}

.alert-error {
  background: rgba(255, 111, 97, 0.12);
  border: 1px solid rgba(255, 111, 97, 0.35);
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---- Accessibility helpers ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--urra-secondary);
  outline-offset: 2px;
}

/* ---- Tab navigation ---- */
.tab-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0 1.25rem;
  margin: 0.4rem 0 0.9rem;
  border-bottom: 1px solid rgba(226, 88, 34, 0.2);
}

.tab-btn {
  border: 0;
  background: transparent;
  padding: 0.65rem 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0;
}

.tab-btn:hover {
  color: var(--urra-primary);
}

.tab-btn[aria-selected="true"] {
  color: var(--urra-primary);
  border-bottom-color: var(--urra-primary);
}

.tab-panel.is-hidden {
  display: none;
}

/* ---- Overview details ---- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
  margin: 0.8rem 0 0;
}

.detail-grid > div {
  background: var(--surface-soft);
  border: 1px solid rgba(226, 88, 34, 0.18);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}

.detail-grid dt {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.detail-grid dd {
  margin: 0.15rem 0 0;
  font-weight: 700;
  color: #111827;
  word-break: break-word;
}
.connection-detail dt { display: flex; align-items: center; gap: .35rem; }
.connection-detail dt i { color: var(--urra-primary); }
.connection-detail small { display: block; color: var(--text-muted); font-size: .75rem; margin-top: .3rem; }

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

.muted.small {
  font-size: 0.82rem;
  display: block;
}

.feedback {
  min-height: 1.2rem;
  color: var(--text-muted);
}

.feedback.error {
  color: var(--bad);
}

.feedback.ok {
  color: var(--ok);
}

/* ---- Console toolbar ---- */
.logs-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.logs-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

#logsSearch {
  border: 1px solid rgba(226, 88, 34, 0.35);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}

.logs-box mark {
  background: #fde047;
  color: #111827;
}

/* ---- Files tab ---- */
.files-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.files-toolbar select {
  border: 1px solid rgba(226, 88, 34, 0.35);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}

.breadcrumb {
  font-family: monospace;
  color: var(--text-muted);
}

.quota-label {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.drop-zone {
  border: 2px dashed rgba(226, 88, 34, 0.4);
  border-radius: 12px;
  padding: 1.4rem;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.drop-zone.is-dragover {
  background: var(--surface-soft);
  border-color: var(--urra-secondary);
}

.link-like {
  color: var(--urra-primary);
  text-decoration: underline;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
}

.upload-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.upload-progress-wrap progress {
  flex: 1;
}

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

.file-table th,
.file-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid rgba(226, 88, 34, 0.15);
}

.file-table .row-actions {
  display: flex;
  gap: 0.4rem;
}

.file-table .row-actions .btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
}

.empty-state.is-hidden {
  display: none;
}

/* ---- Software / catalog tab ---- */
.install-form {
  display: grid;
  gap: 0.5rem;
  max-width: 420px;
}

.install-form select {
  border: 1px solid rgba(226, 88, 34, 0.35);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}

/* ---- Activity tab ---- */
.activity-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.activity-list li {
  background: var(--surface-soft);
  border: 1px solid rgba(226, 88, 34, 0.18);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
}

.activity-list time {
  color: var(--text-muted);
  font-size: 0.8rem;
  display: block;
}

/* ---- Confirm dialog ---- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: grid;
  place-items: center;
  z-index: 50;
}

.dialog-overlay.is-hidden {
  display: none;
}

.dialog-box {
  background: #ffffff;
  border-radius: 14px;
  padding: 1.25rem;
  width: min(420px, 90vw);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1rem;
}

.danger-text {
  color: #d0342c;
  font-weight: 700;
  margin: 0.6rem 0 0;
}

.danger-text.is-hidden {
  display: none;
}

.progress-track {
  margin-top: 1rem;
  height: 10px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(110deg, var(--urra-primary), #f2782e);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-fill.is-indeterminate {
  width: 40%;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

@media (max-width: 860px) {
  .control-row {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row {
    justify-content: flex-start;
  }

  .brand-logo {
    width: 58px;
    height: 58px;
  }
}

/* ---- Dashboard application shell -------------------------------------- */
.dashboard-shell { min-height: 100%; display: grid; grid-template-columns: 260px minmax(0, 1fr); position: relative; }
.sidebar { background: #172033; color: #dbe5f4; min-height: 100%; padding: 1.35rem 1rem 1rem; display: flex; flex-direction: column; gap: 1.75rem; border-right: 1px solid rgba(255,255,255,.08); }
.sidebar .brand-wrap { color: #fff; text-decoration: none; padding: 0 .5rem; }
.sidebar .brand-wrap span { display: grid; gap: .1rem; }
.sidebar .brand-wrap small, .sidebar-user small { color: #9aaac1; font-size: .78rem; }
.sidebar .brand-logo { width: 42px; height: 42px; }
.tab-bar { display: grid; gap: .35rem; padding: 0; margin: 0; border: 0; }
.tab-btn { width: 100%; display: flex; align-items: center; gap: .8rem; color: #b6c3d5; text-align: left; padding: .75rem .8rem; border: 1px solid transparent; border-radius: 10px; }
.tab-btn i { font-size: 1.15rem; width: 1.25rem; text-align: center; }
.tab-btn:hover { color: #fff; background: rgba(255,255,255,.07); }
.tab-btn[aria-selected="true"] { color: #fff; background: linear-gradient(110deg, var(--urra-primary), #f2782e); border-color: rgba(255,255,255,.14); }
.sidebar-user { margin-top: auto; display: flex; gap: .65rem; align-items: center; padding: .7rem .5rem; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user > span:nth-child(2) { display: grid; flex: 1; min-width: 0; }
.sidebar-user strong { overflow: hidden; text-overflow: ellipsis; }
.user-avatar { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; background: #f47a38; color: white; font-weight: 800; }
.icon-btn { border: 0; background: transparent; color: #b6c3d5; cursor: pointer; padding: .45rem; font-size: 1.15rem; border-radius: 7px; }
.icon-btn:hover { color: white; background: rgba(255,255,255,.1); }
.dashboard-main { min-width: 0; background: #fbfcfe; display: flex; flex-direction: column; justify-content: space-around; }
.panel-header { padding: 1.8rem 2rem 1rem; }
.panel-header h1 { font-size: clamp(1.35rem, 2vw, 1.8rem); }
.eyebrow { margin: 0 0 .15rem; color: var(--urra-primary); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; }
.header-status { display: inline-flex; gap: .4rem; align-items: center; color: #18794e; font-size: .9rem; background: #eaf8ef; border-radius: 999px; padding: .4rem .7rem; }
.dashboard-grid { padding: .5rem 2rem 2rem; }
.card-heading { display: flex; align-items: center; gap: .65rem; }
.card-heading > i { color: var(--urra-primary); font-size: 1.25rem; }
.card-heading p { margin: .2rem 0 0; }
.uptime-group > i { color: var(--urra-primary); font-size: 1.25rem; }
.drop-zone > i { color: var(--urra-primary); font-size: 2rem; }

/* ---- Software picker --------------------------------------------------- */
.software-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: .7rem; margin: 1.25rem 0; }
.software-card { display: grid; justify-items: start; gap: .25rem; min-height: 118px; padding: .85rem; border: 1px solid #e6eaf0; border-radius: 13px; cursor: pointer; text-align: left; background: #fff; color: var(--text-main); transition: transform .15s, box-shadow .15s, border-color .15s; }
.software-card:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(18, 33, 54, .09); border-color: rgba(226, 88, 34, .55); }
.software-card.is-selected { border-color: var(--urra-primary); background: #fff7f2; box-shadow: 0 0 0 3px rgba(226,88,34,.13); }
.software-card i { font-size: 1.5rem; color: var(--urra-primary); }
.software-card-icon { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; }
.software-card small { color: var(--text-muted); }
.catalog-actions { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.install-form { margin-top: 1rem; }
.install-form.is-hidden { display: none; }
.wizard-step-label { margin: 1.1rem 0 .1rem; font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.wizard-step-label:first-of-type { margin-top: .6rem; }
#editionWrap.is-hidden { display: none; }

/* ---- Users ------------------------------------------------------------- */
.user-form { display: grid; grid-template-columns: 1fr 1fr minmax(120px, .5fr) auto; gap: .6rem; margin: 1.25rem 0 .4rem; }
.user-form select, .files-toolbar select, .install-form select { border: 1px solid rgba(226,88,34,.35); border-radius: 10px; background: #fff; padding: .6rem .7rem; color: var(--text-main); }
.users-list { display: grid; gap: .5rem; margin-top: .7rem; }
.user-row { display: flex; gap: .75rem; align-items: center; padding: .75rem; border: 1px solid #e6eaf0; border-radius: 10px; }
.user-row .user-avatar { background: #34445e; }
.user-row-info { flex: 1; display: grid; gap: .1rem; }
.user-row small { color: var(--text-muted); }
.role-pill { font-size: .75rem; color: #9a3412; background: #fff0e8; border-radius: 999px; padding: .25rem .5rem; }

@media (max-width: 860px) {
  .dashboard-shell { display: flex; flex-direction: column; }
  .sidebar { min-height: auto; gap: .8rem; padding: .8rem; }
  .sidebar .brand-wrap { padding: 0; }
  .tab-bar { grid-template-columns: repeat(3, 1fr); }
  .tab-btn { justify-content: center; padding: .6rem; }
  .tab-btn span { font-size: .78rem; }
  .sidebar-user { margin-top: 0; border-top: 0; }
  .panel-header, .dashboard-grid { padding-left: 1rem; padding-right: 1rem; }
  .panel-header { padding-top: 1.25rem; }
  .user-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .tab-bar { grid-template-columns: repeat(2, 1fr); }
  .tab-btn { justify-content: flex-start; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .software-grid { grid-template-columns: repeat(2, 1fr); }
  .user-form { grid-template-columns: 1fr; }
  .user-row { flex-wrap: wrap; }
}
