:root {
  --bg: #10140f;
  --bg-2: #171d16;
  --panel: #1c241b;
  --line: #2d3a2a;
  --text: #e8eee4;
  --muted: #93a38c;
  --lime: #c6f355;
  --lime-2: #9ad12a;
  --warn: #f0b429;
  --danger: #ff6b4a;
  --ok: #7ee787;
  --blue: #9ecbff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, #2a3d1c 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: Outfit, system-ui, sans-serif;
}

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

a {
  color: inherit;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--lime);
  color: #172012;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.brand h1,
.brand .title {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.sub {
  color: var(--muted);
  margin: 8px 0 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  background: #12180f;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--lime-2);
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn-lime {
  background: var(--lime);
  color: #172012;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-danger {
  background: #3a1c16;
  color: #ffb4a4;
  border: 1px solid #5a2a22;
}

.btn-ssh {
  background: #172012;
  color: var(--lime);
  border: 1px solid #3d5a24;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  background: rgba(16, 20, 15, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav {
  display: flex;
  gap: 8px;
}

.nav a {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted);
}

.nav a.active,
.nav a:hover {
  background: var(--panel);
  color: var(--text);
}

.shell {
  padding: 22px;
  max-width: 1480px;
  margin: 0 auto;
}

.btn-ico {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.btn-ico .ico,
.btn-ico svg {
  width: 16px;
  height: 16px;
  display: block;
}

.btn-ico svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-actions {
  flex-wrap: nowrap;
  gap: 6px;
}

.col-actions {
  width: 1%;
  white-space: nowrap !important;
}

.col-actions .icon-actions {
  display: inline-flex;
}

.vps-table table {
  min-width: 980px;
}

.vps-table td,
.vps-table th {
  vertical-align: middle;
  white-space: nowrap;
  padding: 6px 10px;
  line-height: 1.2;
}

.vps-table tbody td {
  height: 44px;
  max-height: 44px;
}

.vps-table .btn-ico {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.vps-table .btn-ico svg {
  width: 14px;
  height: 14px;
}

.btn-cf-on {
  color: #f6821f;
  border-color: rgba(246, 130, 31, 0.45);
  background: rgba(246, 130, 31, 0.12);
}

.btn-cf-off {
  color: var(--muted);
}

.dns-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dns-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}

.dns-zone-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  cursor: pointer;
  padding: 10px 12px;
  user-select: none;
}

.dns-zone-bar > .ico {
  flex-shrink: 0;
  transition: transform 0.22s ease;
  transform: rotate(-90deg);
}

.dns-group.open .dns-zone-bar > .ico {
  transform: rotate(0deg);
}

.dns-zone-bar .btn-ico {
  margin-left: auto;
}

.dns-fold {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s ease;
}

.dns-group.open .dns-fold {
  grid-template-rows: 1fr;
}

.dns-fold-inner {
  overflow: hidden;
  min-height: 0;
}

.dns-fold-inner .table-wrap {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.dns-fold-inner .vps-table table {
  min-width: 0;
  width: 100%;
}

tr.dns-rec td:first-child {
  padding-left: 18px;
}

tr.dns-rec td.mono {
  font-size: 13px;
}

.vps-table .icon-actions {
  gap: 4px;
}

.vps-table td.clip {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vps-name {
  font-weight: 600;
  letter-spacing: -0.02em;
}

.vps-name .badge {
  margin-left: 8px;
  vertical-align: middle;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.stat b {
  display: block;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  min-width: 180px;
}

.grow {
  flex: 1;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card:hover {
  border-color: #4a6238;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.host {
  font-family: "IBM Plex Mono", monospace;
  color: var(--blue);
  font-size: 13px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 4px;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
}

.ok {
  background: #16341c;
  color: var(--ok);
}

.soon {
  background: #3a2d0e;
  color: var(--warn);
}

.expired {
  background: #3a1c16;
  color: var(--danger);
}

.unknown {
  background: #222;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

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

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 500;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
}

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.modal {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.err {
  color: var(--danger);
  margin-top: 10px;
}

.secret {
  background: #12180f;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

.term-page {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #0a0e09;
}

.term-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #151c13 0%, #0f140e 100%);
  border-bottom: 1px solid var(--line);
}

.term-bar-id {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.term-bar-id strong {
  font-size: 15px;
  letter-spacing: -0.03em;
}

.term-host {
  font-family: "IBM Plex Mono", monospace;
  color: var(--blue);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: #12180f;
  border: 1px solid var(--line);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.status-pill.live .dot {
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime);
  animation: pulse 1.6s ease infinite;
}

.status-pill.bad .dot {
  background: var(--danger);
}

.status-pill.wait .dot {
  background: var(--warn);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
  gap: 10px;
  padding: 10px;
}

.workspace.files-only {
  grid-template-columns: 1fr;
}

.workspace.term-only {
  grid-template-columns: 1fr;
}

.workspace.files-only .term-pane,
.workspace.term-only .files-pane {
  display: none;
}

.pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #101610;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

.chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: #171e15;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.traffic {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.traffic i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: block;
}

.traffic .r {
  background: #ff6b6b;
}

.traffic .y {
  background: #f0c14a;
}

.traffic .g {
  background: #7ee787;
}

.chrome-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "IBM Plex Mono", monospace;
}

.term-body {
  min-height: 0;
  background: #0b0f0a;
  padding: 6px 8px 10px;
}

#terminal {
  height: 100%;
  background: #0b0f0a;
}

.xterm,
.xterm-viewport {
  height: 100%;
}

.xterm .xterm-viewport {
  overflow-y: auto;
}

.files-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #141b12;
  flex-wrap: wrap;
}

.crumb {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-width: 0;
  flex: 1;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.crumb button {
  background: transparent;
  border: 0;
  color: var(--blue);
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
}

.crumb button:hover {
  background: #1d2819;
  color: var(--text);
}

.crumb span {
  color: var(--muted);
}

.file-list {
  overflow: auto;
  min-height: 0;
}

.file-row {
  display: grid;
  grid-template-columns: 28px 1fr 90px 140px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #1c2519;
  cursor: pointer;
  font-size: 13px;
}

.file-row:hover,
.file-row.sel {
  background: #1a2417;
}

.file-row.sel {
  outline: 1px solid #3d5a24;
}

.file-ico {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: #1c2818;
}

.file-row.dir .file-ico {
  background: #24351b;
  color: var(--lime);
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size,
.file-time {
  color: var(--muted);
  font-size: 12px;
  font-family: "IBM Plex Mono", monospace;
}

.files-pane {
  position: relative;
}

.file-drop.over::after {
  content: "Thả file để upload";
  position: absolute;
  inset: 8px;
  border: 1px dashed var(--lime-2);
  border-radius: 12px;
  background: rgba(198, 243, 85, 0.08);
  display: grid;
  place-items: center;
  color: var(--lime);
  font-weight: 600;
  pointer-events: none;
}

.editor-wrap {
  position: absolute;
  inset: 0;
  background: #0f140e;
  display: grid;
  grid-template-rows: auto 1fr auto;
  z-index: 2;
}

.editor-wrap textarea {
  border: 0;
  border-radius: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  min-height: 0;
  height: 100%;
}

.btn-sm {
  padding: 7px 10px;
  font-size: 12px;
}

.seg {
  display: flex;
  background: #12180f;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
}

.seg button {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.seg button.on {
  background: #22331b;
  color: var(--lime);
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .file-row {
    grid-template-columns: 28px 1fr 80px;
  }
  .file-time {
    display: none;
  }
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions.icon-actions {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}

.empty {
  color: var(--muted);
  padding: 40px 10px;
  text-align: center;
}

.card-title {
  font-size: 20px;
  letter-spacing: -0.03em;
}

.clip-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-cta,
.tabbar,
.fab {
  display: none;
}

.ico svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

@media (max-width: 760px) {
  html,
  body {
    background: var(--bg);
  }

  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  input,
  select,
  textarea,
  .btn {
    font-size: 16px;
  }

  .desk-only {
    display: none !important;
  }

  .nav {
    display: none;
  }

  .top {
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    gap: 10px;
  }

  .brand .sub {
    display: none;
  }

  .brand .title {
    font-size: 18px;
  }

  .top .actions .btn {
    min-height: 40px;
    padding: 8px 12px;
  }

  .page {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .shell {
    padding: 12px 12px 24px;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .stat {
    padding: 12px;
    border-radius: 14px;
  }

  .stat b {
    font-size: 22px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .toolbar input,
  .toolbar select,
  .toolbar .grow {
    min-width: 0;
    width: 100%;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .card {
    min-height: 0;
    padding: 14px;
    border-radius: 16px;
    gap: 8px;
  }

  .vps-card {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .vps-card .icon-actions {
    display: none;
  }

  .card-cta {
    display: grid;
    grid-template-columns: 1.2fr 1fr 0.8fr;
    gap: 8px;
    margin-top: 6px;
  }

  .card-cta .btn {
    min-height: 44px;
    width: 100%;
    justify-content: center;
  }

  .card-title {
    font-size: 18px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2,
  .form-grid .field {
    grid-column: span 1;
  }

  .modal-bg {
    align-items: end;
    place-items: end center;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: min(92dvh, 920px);
    border-radius: 20px 20px 0 0;
    padding: 16px 16px max(18px, env(safe-area-inset-bottom));
  }

  .modal .actions {
    position: sticky;
    bottom: 0;
    background: var(--bg-2);
    padding-top: 10px;
  }

  .modal .actions .btn {
    flex: 1;
    min-height: 46px;
  }

  .vps-table table {
    min-width: 0;
    width: 100%;
  }

  .vps-table thead {
    display: none;
  }

  .vps-table tbody,
  .vps-table table {
    display: block;
  }

  .vps-table tr.dns-rec {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 6px 8px;
    padding: 12px;
    height: auto;
    max-height: none;
    border-bottom: 1px solid var(--line);
  }

  .vps-table tr.dns-rec td {
    border: 0;
    padding: 0;
    height: auto;
    max-height: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .vps-table tr.dns-rec td:nth-child(1) {
    font-weight: 700;
    color: var(--lime);
  }

  .vps-table tr.dns-rec td:nth-child(3) {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 13px;
  }

  .vps-table tr.dns-rec td:nth-child(4) {
    grid-column: 1;
  }

  .vps-table tr.dns-rec td:nth-child(5) {
    grid-column: 2 / -1;
  }

  .vps-table tr.dns-rec td:nth-child(5) select {
    width: 100%;
  }

  .vps-table tr.dns-rec td.col-actions {
    grid-column: 3;
    grid-row: 1 / span 2;
    width: auto;
    white-space: nowrap !important;
  }

  .vps-table .btn-ico {
    width: 40px;
    height: 40px;
  }

  .dns-zone-bar {
    min-height: 52px;
    padding: 12px;
    gap: 8px;
  }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    justify-content: space-around;
    gap: 4px;
    padding: 6px 8px max(8px, env(safe-area-inset-bottom));
    background: rgba(16, 20, 15, 0.94);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }

  .tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 4px;
    border-radius: 12px;
    min-height: 52px;
    justify-content: center;
  }

  .tabbar a.active {
    color: var(--lime);
    background: #1a2416;
  }

  .tabbar .ico svg {
    width: 22px;
    height: 22px;
  }

  .fab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    right: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    z-index: 25;
    min-height: 48px;
    padding: 0 16px;
    border-radius: 999px;
    box-shadow: var(--shadow);
  }

  .fab .ico svg {
    width: 18px;
    height: 18px;
  }

  .term-page.is-phone .term-bar {
    flex-wrap: wrap;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    gap: 8px;
  }

  .term-page.is-phone .term-bar-id {
    width: 100%;
  }

  .term-page.is-phone .term-bar .actions {
    width: 100%;
    justify-content: space-between;
  }

  .term-page.is-phone .seg {
    flex: 1;
  }

  .term-page.is-phone .seg button {
    flex: 1;
    min-height: 40px;
  }

  .term-page.is-phone .workspace {
    padding: 8px;
    grid-template-rows: 1fr;
  }

  .term-page.is-phone .chrome {
    gap: 6px;
  }

  .term-page.is-phone .traffic {
    display: none;
  }

  .term-page.is-phone .chrome .btn {
    min-height: 36px;
  }

  .file-row {
    grid-template-columns: 28px 1fr;
    min-height: 48px;
  }

  .file-size,
  .file-time {
    display: none;
  }
}

@media (max-width: 860px) {
  .stats,
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
  .span-2,
  .form-grid .field {
    grid-column: span 2;
  }
  .top {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .stats {
    grid-template-columns: 1fr;
  }
}
