/* AIOps Console — Apple-internal-tool aesthetic
 * System font stack, frosted chrome, restrained color, precise spacing.
 */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.07);
  --radius: 12px;
  --radius-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  font-size: 14px;
}

.mono {
  font-family: var(--mono);
}

.hidden {
  display: none !important;
}

/* ----- Top bar ----- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(251, 251, 253, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  width: min(1240px, 94vw);
  margin: 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 22px;
  width: auto;
}

.brand-divider {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
}

.brand-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: #f0f0f2;
  color: var(--text);
}

.back-btn {
  display: none;
}

.detail-page-active .back-btn {
  display: inline-flex;
}

/* ----- Segmented control ----- */

.segmented {
  display: inline-flex;
  background: rgba(118, 118, 128, 0.12);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.segmented-option {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 5px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.segmented-option.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.segmented-sm .segmented-option {
  padding: 4px 10px;
  font-size: 0.75rem;
}

/* ----- Layout ----- */

.container {
  width: min(1240px, 94vw);
  margin: 28px auto 60px;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.view-title {
  margin: 0 0 2px;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.view-subtitle {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ----- Fleet summary ----- */

.fleet-summary {
  display: flex;
  gap: 10px;
}

.summary-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 86px;
  box-shadow: var(--shadow-sm);
}

.summary-stat span:last-child {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-num {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stat-good .summary-num {
  color: var(--green);
}

.stat-bad .summary-num {
  color: var(--orange);
}

/* ----- Fleet grid ----- */

.region-group {
  margin-bottom: 28px;
}

.region-title {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.server-card {
  text-align: left;
  font-family: var(--font);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.server-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.server-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.server-name {
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.server-host {
  margin: 4px 0 12px;
  color: var(--text-tertiary);
  font-size: 0.74rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-card-body {
  display: grid;
  gap: 7px;
}

.server-error {
  margin: 0;
  color: var(--red);
  font-size: 0.8rem;
}

.server-stats-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.chip {
  background: rgba(0, 113, 227, 0.08);
  color: var(--accent);
  font-size: 0.71rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 9px;
}

.chip-muted {
  background: rgba(118, 118, 128, 0.1);
  color: var(--text-secondary);
}

.note-badge {
  background: rgba(255, 159, 10, 0.14);
  color: #c77700;
  font-size: 0.69rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 9px;
  cursor: help;
}

/* ----- Status pills ----- */

.status-pill {
  display: inline-block;
  font-size: 0.69rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.pill-online {
  background: rgba(52, 199, 89, 0.14);
  color: #1d8a3e;
}

.pill-offline {
  background: rgba(255, 59, 48, 0.12);
  color: #c4271e;
}

.pill-probing {
  background: rgba(118, 118, 128, 0.12);
  color: var(--text-tertiary);
}

/* ----- Metric bars (fleet cards) ----- */

.metric-row {
  display: grid;
  grid-template-columns: 36px 1fr 52px;
  align-items: center;
  gap: 10px;
}

.metric-label {
  font-size: 0.71rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.metric-track,
.tile-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.14);
  overflow: hidden;
  display: block;
}

.metric-fill,
.tile-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.metric-fill.ok,
.tile-fill.ok {
  background: var(--green);
}

.metric-fill.warn,
.tile-fill.warn {
  background: var(--orange);
}

.metric-fill.crit,
.tile-fill.crit {
  background: var(--red);
}

.metric-value {
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--text-secondary);
  text-align: right;
}

/* ----- Skeletons ----- */

@keyframes shimmer {
  0% { opacity: 0.45; }
  50% { opacity: 0.9; }
  100% { opacity: 0.45; }
}

.skeleton-line {
  height: 10px;
  border-radius: 6px;
  background: rgba(118, 118, 128, 0.14);
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-line.short {
  width: 60%;
}

.skeleton-tiles {
  height: 96px;
  border-radius: var(--radius-lg);
  background: rgba(118, 118, 128, 0.1);
  animation: shimmer 1.4s ease-in-out infinite;
  grid-column: 1 / -1;
}

/* ----- Metric tiles (detail) ----- */

.metric-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: grid;
  gap: 3px;
  box-shadow: var(--shadow-sm);
}

.tile-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tile-value {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tile-sub {
  font-size: 0.73rem;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-tile .tile-track {
  margin-top: 7px;
}

/* ----- Panel & table ----- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  font-family: var(--font);
  font-size: 0.82rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 6px 11px;
  min-width: 190px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}

.table-wrap {
  overflow: auto;
  width: 100%;
}

.containers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.containers-table th,
.containers-table td {
  border-bottom: 1px solid var(--border);
  padding: 11px 14px;
  text-align: left;
  vertical-align: top;
}

.containers-table tbody tr:last-child td {
  border-bottom: none;
}

.containers-table tbody tr:hover {
  background: var(--surface-2);
}

.containers-table th {
  color: var(--text-tertiary);
  font-size: 0.69rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface-2);
  position: sticky;
  top: 0;
}

.container-name-wrap {
  display: grid;
  gap: 3px;
}

.container-id {
  color: var(--text-tertiary);
  font-size: 0.7rem;
}

.image-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.state-sub {
  margin-top: 4px;
  font-size: 0.71rem;
  color: var(--text-tertiary);
}

.stat-cell {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.ports-cell {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.empty-cell {
  color: var(--text-tertiary);
  text-align: center;
  padding: 28px !important;
}

.th-actions {
  width: 280px;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ----- Buttons ----- */

.btn {
  font-family: var(--font);
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: -0.005em;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-xs {
  padding: 4px 9px;
  font-size: 0.73rem;
  border-radius: 7px;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: rgba(118, 118, 128, 0.1);
  color: var(--text);
}

.btn-secondary:hover {
  background: rgba(118, 118, 128, 0.18);
}

.btn-success {
  background: rgba(52, 199, 89, 0.14);
  color: #1d8a3e;
}

.btn-success:hover {
  background: rgba(52, 199, 89, 0.24);
}

.btn-warn {
  background: rgba(255, 159, 10, 0.14);
  color: #c77700;
}

.btn-warn:hover {
  background: rgba(255, 159, 10, 0.26);
}

.btn-danger,
.btn-danger-ghost {
  background: rgba(255, 59, 48, 0.12);
  color: #c4271e;
}

.btn-danger {
  background: var(--red);
  color: #ffffff;
}

.btn-danger:hover {
  background: #e0342a;
}

.btn-danger-ghost:hover {
  background: rgba(255, 59, 48, 0.22);
}

.btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* ----- Auto refresh toggle ----- */

.auto-refresh-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.auto-refresh-toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

/* ----- Modals ----- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.modal-fullscreen {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: 0;
  border: none;
  overflow: hidden;
}

.modal-drawer {
  width: min(540px, 94vw);
  max-height: 86vh;
  border-radius: var(--radius-lg);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.modal-dialog {
  width: min(420px, 92vw);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.modal-dialog h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.confirm-message {
  margin: 0 0 18px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.45;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}

.modal-header h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.conn-pill {
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(118, 118, 128, 0.12);
  color: var(--text-tertiary);
}

.conn-live {
  background: rgba(52, 199, 89, 0.14);
  color: #1d8a3e;
}

.conn-error {
  background: rgba(255, 59, 48, 0.12);
  color: #c4271e;
}

.conn-ended {
  background: rgba(255, 159, 10, 0.14);
  color: #c77700;
}

/* ----- Logs & terminal ----- */

.log-output {
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d8dee9;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  background: #1c1c1e;
}

.terminal-root {
  width: 100%;
  min-height: 0;
  padding: 0;
  background: #1c1c1e;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
}

.terminal-root .xterm {
  height: 100% !important;
  background: #1c1c1e !important;
  overflow: hidden;
}

.terminal-root .xterm-screen {
  height: 100% !important;
}

.terminal-root .xterm-viewport {
  background: #1c1c1e !important;
  overflow-y: hidden !important;
  scrollbar-width: none;
}

.terminal-root .xterm-viewport::-webkit-scrollbar {
  display: none;
}

.terminal-footer {
  display: none;
}

/* ----- Inspect drawer ----- */

.inspect-body {
  padding: 16px 18px;
  overflow: auto;
}

.inspect-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 7px 14px;
  margin: 0;
}

.inspect-grid dt {
  font-size: 0.74rem;
  font-weight: 650;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: center;
}

.inspect-grid dd {
  margin: 0;
  font-size: 0.79rem;
  word-break: break-all;
}

.inspect-section {
  margin: 18px 0 8px;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mount-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  display: grid;
  gap: 4px;
}

/* ----- Toasts ----- */

.toast-root {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: rgba(29, 29, 31, 0.92);
  backdrop-filter: blur(10px);
  color: #f5f5f7;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  max-width: 380px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-left: 3px solid var(--green);
}

.toast-error {
  border-left: 3px solid var(--red);
}

/* ----- File browser ----- */

.modal-drawer-wide {
  width: min(720px, 96vw);
}

.file-browser-body {
  padding: 16px 18px;
  display: grid;
  gap: 16px;
  overflow: auto;
  height: 100%;
  grid-template-rows: auto 1fr auto;
}

.file-path-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.file-path-input {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.file-list {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.file-entry {
  display: grid;
  grid-template-columns: 24px 1fr auto auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.file-entry:last-child {
  border-bottom: none;
}

.file-entry:hover {
  background: rgba(0, 113, 227, 0.04);
}

.file-icon {
  font-size: 1rem;
  line-height: 1;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.file-name-dir {
  color: var(--accent);
  cursor: pointer;
}

.file-meta {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.file-size {
  font-size: 0.72rem;
  color: var(--text-secondary);
  min-width: 50px;
  text-align: right;
}

.file-modified {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  min-width: 100px;
}

.file-dl-btn {
  justify-self: end;
}

.file-list-loading,
.file-list-empty,
.file-list-error {
  padding: 28px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.84rem;
}

.file-list-error {
  color: var(--red);
}

.file-download-progress {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}

.file-download-progress.hidden {
  display: none;
}

.file-download-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.file-download-name {
  font-weight: 600;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}

.file-download-stats {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: var(--mono);
}

.file-progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.file-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.file-progress-error {
  background: var(--red);
}

.file-direct-download {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.file-direct-download label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: block;
}

.file-direct-row {
  display: flex;
  gap: 8px;
}

.file-direct-row .form-input {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.82rem;
}

/* ----- Add Server form ----- */

.add-server-body {
  padding: 20px;
  display: grid;
  gap: 18px;
  overflow: auto;
}

.form-group {
  display: grid;
  gap: 5px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.optional {
  font-weight: 500;
  text-transform: none;
  color: var(--text-tertiary);
  letter-spacing: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-input {
  font-family: var(--font);
  font-size: 0.88rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 9px 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}

.form-input-file {
  font-family: var(--font);
  font-size: 0.84rem;
  padding: 8px 0;
  color: var(--text-secondary);
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.form-error {
  margin: 0;
  padding: 10px 14px;
  background: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: 8px;
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 500;
}

.form-actions {
  padding-top: 4px;
}

.btn-lg {
  padding: 11px 22px;
  font-size: 0.9rem;
  width: 100%;
}

.view-head-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ----- Responsive ----- */

@media (max-width: 740px) {
  .container {
    margin: 18px auto 40px;
  }

  .topbar-inner {
    height: auto;
    padding: 8px 0;
    flex-wrap: wrap;
  }

  .brand-title {
    display: none;
  }

  .view-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .server-grid {
    grid-template-columns: 1fr;
  }

  .th-actions {
    width: auto;
  }

  .search-input {
    min-width: 130px;
    flex: 1;
  }
}

/* ----- S3 Editor ----- */

.s3-editor-textarea {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: none;
  outline: none;
  resize: none;
  padding: 18px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: #d8dee9;
  background: #1c1c1e;
  overflow: auto;
}

.s3-editor-textarea:disabled {
  opacity: 0.5;
}

/* ----- User Menu ----- */

.user-menu {
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s;
}

.user-btn:hover {
  background: var(--border);
}

.user-name {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  overflow: hidden;
}

.user-dropdown-info {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-role-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
}

.user-dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--red);
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}

.user-dropdown-item:hover {
  background: rgba(255, 59, 48, 0.06);
}

/* ----- Settings Page ----- */

.settings-content {
  display: grid;
  gap: 24px;
}

.settings-info-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.settings-info-panel h3 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.perm-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.perm-card h4 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
}

.perm-card ul {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: disc;
}

.perm-card li {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.perm-card li.perm-denied {
  color: var(--red);
  font-weight: 500;
}

.text-muted {
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ----- Restricted (no-permission) buttons ----- */

.btn-restricted {
  position: relative;
  opacity: 0.45;
  cursor: not-allowed !important;
  pointer-events: auto;
}

.btn-restricted:hover::after {
  content: "🚫 No permission";
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 50;
}
