/* ctrl. design system — client */
:root {
  --ctrl-red: #e11d2e;
  --ctrl-red-dark: #c41222;
  --bg: #ffffff;
  --panel: #f8fafc;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --blue: #2563eb;
  --green: #16a34a;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.client-top {
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 22px; letter-spacing: -0.03em;
}
.brand .cube {
  width: 28px; height: 28px; border-radius: 7px; background: var(--ctrl-red);
  box-shadow: inset -4px -4px 0 rgba(0,0,0,.12); position: relative;
}
.brand .cube:before {
  content: ""; position: absolute; inset: 5px;
  border: 2px solid rgba(255,255,255,.9); border-radius: 3px;
}
.nav { display: flex; gap: 22px; }
.nav a { color: #4b5563; font-weight: 600; padding-bottom: 16px; margin-bottom: -15px; border-bottom: 2px solid transparent; }
.nav a.active { color: var(--text); border-bottom-color: var(--ctrl-red); }
.right { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 999px; background: #111827; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 28px 40px; }
.crumbs { color: var(--blue); font-size: 13px; margin-bottom: 10px; }
.crumbs span { color: var(--muted); }
.head-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px;
}
.head-row h1 { margin: 0; font-size: 34px; letter-spacing: -0.04em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 10px; padding: 10px 14px; border: 1px solid var(--border);
  background: #fff; color: var(--text); cursor: pointer; font-weight: 600;
}
.btn:hover { background: #f8fafc; color: var(--text); }
.btn-primary:hover { background: var(--ctrl-red-dark); border-color: var(--ctrl-red-dark); color: #fff; }
.btn-blue:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.btn-red:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-red { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-primary { background: var(--ctrl-red); border-color: var(--ctrl-red); color: #fff; }
.btn-outline { background: #fff; }
.pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 700; border: 1px solid transparent;
}
.pill.online { background: #ecfdf5; color: #067647; border-color: #a7f3d0; }
.pill.offline { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.pill.suspended { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.pill.unknown { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }

.meta {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  margin-bottom: 14px; background: #fff; box-shadow: var(--shadow);
}
.meta .cell { padding: 14px 16px; border-right: 1px solid var(--border); }
.meta .cell:last-child { border-right: 0; }
.meta .k { color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.meta .v { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }

.usage {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px;
}
.usage .card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  background: #fff; box-shadow: var(--shadow);
}
.usage .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.usage .pct { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.usage .label { color: var(--muted); font-weight: 600; font-size: 13px; }
.usage .detail { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.bar { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: #94a3b8; }
.bar.green > span { background: #22c55e; }

.tabs {
  display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.tabs a {
  padding: 10px 2px 12px; color: #6b7280; font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--ctrl-red); }

.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 14px; }
.panel {
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  box-shadow: var(--shadow); overflow: hidden;
}
.panel h3 {
  margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 15px;
}
.kv { padding: 6px 0; }
.kv .row {
  display: grid; grid-template-columns: 140px 1fr; gap: 10px;
  padding: 9px 16px; border-bottom: 1px solid #f3f4f6;
}
.kv .row:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); font-weight: 600; }
.kv .v { font-weight: 600; word-break: break-all; }
.activity { padding: 8px 0; }
.activity .item {
  display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #f3f4f6;
}
.activity .item:last-child { border-bottom: 0; }
.activity .dot {
  width: 22px; height: 22px; border-radius: 999px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0;
}
.dot.ok { background: #dcfce7; color: #15803d; }
.dot.info { background: #dbeafe; color: #1d4ed8; }
.activity .title { font-weight: 700; }
.activity .desc { color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.flash { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: #374151; margin-bottom: 6px; font-weight: 600; }
.field input, .field select {
  width: 100%; max-width: 420px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f3f4f6;
}
.login-card {
  width: min(400px, calc(100vw - 32px));
  background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 28px;
  box-shadow: var(--shadow);
}
.list-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: #fff; box-shadow: var(--shadow);
}
.list-card table { width: 100%; border-collapse: collapse; min-width: 520px; }
.list-card th, .list-card td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.list-card th { color: var(--muted); background: #fafafa; font-size: 12px; }

.info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px;
}
.info-table {
  width: 100%; border-collapse: collapse; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow);
}
.info-table th, .info-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.info-table tr:last-child th, .info-table tr:last-child td { border-bottom: 0; }
.info-table th {
  width: 42%; background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 13px;
}
.info-table td { font-weight: 600; }

.usage-table {
  width: 100%; border-collapse: collapse; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.usage-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.usage-table tr:last-child td { border-bottom: 0; }
.usage-table td:first-child { font-weight: 700; width: 160px; }
.usage-table .bar-cell { display: flex; align-items: center; gap: 10px; }
.usage-table .bar { flex: 1; height: 10px; }
.pct-label { font-weight: 700; min-width: 40px; color: var(--muted); font-size: 13px; }

.control-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 18px;
}
.control-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 88px; padding: 12px 8px; border: 1px solid var(--border);
  border-radius: var(--radius); background: #fff; cursor: pointer; font-weight: 600; font-size: 13px;
  text-align: center; box-shadow: var(--shadow); color: inherit;
}
.control-tile:hover { background: #f8fafc; border-color: #cbd5e1; }
.control-tile .ico {
  width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center;
  justify-content: center; background: #f1f5f9; font-size: 16px;
}
.control-tile.boot .ico { background: #dcfce7; color: #15803d; }
.control-tile.shutdown .ico, .control-tile.danger .ico { background: #fee2e2; color: #b91c1c; }
.control-tile.reboot .ico { background: #dbeafe; color: #1d4ed8; }
form:has(.control-tile) { margin: 0; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.inline-setting { margin-bottom: 14px; }
.inline-setting label { display: block; font-weight: 600; margin-bottom: 6px; color: #374151; }
.inline-setting select {
  width: 100%; max-width: 320px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}

.data-plain { width: 100%; border-collapse: collapse; }
.data-plain th, .data-plain td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.data-plain th { color: var(--muted); font-size: 12px; background: #fafafa; }
.rdns-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.rdns-row input {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; }

.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
.modal-card {
  width: min(520px, 100%); background: #fff; border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(0,0,0,.18); overflow: hidden;
}
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; color: var(--text); line-height: 1.5; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 18px 18px;
}
.modal-card h3 { margin: 0; font-size: 18px; }
.twofa-qr-wrap {
  display: flex; justify-content: center; margin: 16px 0;
}
.twofa-qr-wrap img {
  display: block; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px; background: #fff;
}
.maintenance-only {
  max-width: 720px;
  margin: 40px auto 60px;
}
.maintenance-only .error {
  font-size: 15px;
  line-height: 1.6;
  padding: 20px 22px;
}
.error a { color: #1d4ed8; font-weight: 600; text-decoration: underline; }

/* Header actions — visible on white background */
.client-top .right form { margin: 0; flex-shrink: 0; }
.client-top .right .btn {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

@media (max-width: 980px) {
  .meta, .usage, .split, .info-grid, .settings-grid, .account-grid { grid-template-columns: 1fr; }
  .control-grid { grid-template-columns: repeat(3, 1fr); }
  .head-row { flex-direction: column; align-items: stretch; }
  .actions { justify-content: flex-start; }
  .client-top { flex-wrap: wrap; padding: 12px 18px; }
  .wrap { padding: 18px; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .kv .row { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 768px) {
  .client-top {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand right"
      "nav nav";
    align-items: center;
    gap: 10px 12px;
  }
  .client-top .brand { grid-area: brand; font-size: 20px; }
  .client-top .right { grid-area: right; }
  .client-top .nav {
    grid-area: nav;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 18px;
    padding-bottom: 2px;
  }
  .client-top .nav a {
    white-space: nowrap;
    padding-bottom: 8px;
    margin-bottom: 0;
    flex-shrink: 0;
  }
  .head-row h1 { font-size: 26px; }
}

@media (max-width: 640px) {
  .control-grid { grid-template-columns: repeat(2, 1fr); }
  .wrap { padding: 14px 14px 32px; }
  .meta .cell { border-right: 0; border-bottom: 1px solid var(--border); }
  .meta .cell:last-child { border-bottom: 0; }

  /* VPS list: stack rows so Manage is always reachable */
  .list-card { overflow-x: visible; }
  .list-card table { min-width: 0; }
  .list-card thead { display: none; }
  .list-card tbody tr {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }
  .list-card tbody tr:last-child { border-bottom: 0; }
  .list-card td {
    display: block;
    border: 0;
    padding: 3px 0;
    text-align: left;
  }
  .list-card td:first-child { font-size: 16px; padding-top: 0; }
  .list-card td:last-child {
    padding-top: 12px;
    padding-bottom: 4px;
  }
  .list-card td:last-child .btn {
    width: 100%;
    justify-content: center;
  }
  .list-card .empty { display: block; padding: 28px 16px; }

  .info-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-plain { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .rdns-row input { flex: 1; min-width: 0; width: 100%; }
  .field input, .field select { max-width: none; }
  .inline-setting select { max-width: none; }
}

.alert {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  line-height: 1.5;
}
.alert-warning {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
}

.reinstall-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.reinstall-option {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.reinstall-option:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.reinstall-option:has(input:checked) {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
  background: #f8fbff;
}
.reinstall-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.reinstall-option-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}
.reinstall-option-text strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}
.reinstall-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.reinstall-option-mark {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-radius: 999px;
  margin-top: 2px;
}
.reinstall-option:has(input:checked) .reinstall-option-mark {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 4px var(--blue);
}
.reinstall-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 20px 0 8px;
}

@media (max-width: 640px) {
  .reinstall-actions { flex-direction: column; }
  .reinstall-actions .btn { justify-content: center; }
}
