/* Thanh phan giao dien + hieu ung: the, bang, huy hieu, thanh %, dong ho, sparkline, modal, toast, hop xac nhan, Ctrl+K, terminal, skeleton. */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm); transition: border-color .2s, box-shadow .2s, transform .2s; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card.click { cursor: pointer; }
.card.click:hover, .card.hover:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.kpi .card { margin: 0; position: relative; overflow: hidden; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .card::after { content: ""; position: absolute; inset: auto -30px -30px auto; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(color-mix(in srgb, var(--accent, var(--brand)) 16%, transparent), transparent 70%); pointer-events: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.num, td, .v { font-variant-numeric: tabular-nums; }
.copybox { display: flex; gap: 6px; }
.copybox input { font-family: var(--mono); font-size: 12px; }

/* ---- Bang ---- */
.tablewrap { overflow-x: auto; }
.tablewrap.tall { max-height: 70vh; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; position: sticky; top: 0; background: var(--surface); z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: "↕"; opacity: .3; margin-left: 4px; font-size: 10px; }
th.sort-asc::after { content: "↑"; opacity: 1; color: var(--brand); }
th.sort-desc::after { content: "↓"; opacity: 1; color: var(--brand); }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: color-mix(in srgb, var(--brand) 4%, transparent); }
tr.click { cursor: pointer; }
.tfilter { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; max-width: 280px; position: relative; }
.tfilter svg { position: absolute; left: 10px; color: var(--muted); }
.tfilter input { padding-left: 32px; min-height: 32px; font-size: 13px; }
td[colspan].muted { text-align: center; padding: 34px 12px; font-size: 13px; }
td[colspan].muted::before, .empty::before { content: ""; display: block; width: 40px; height: 40px; margin: 0 auto 10px; opacity: .45; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E") center/contain no-repeat; }
.empty { text-align: center; padding: 30px 12px; color: var(--muted); }

/* ---- Huy hieu, tag, cham trang thai ---- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 17%, transparent); color: color-mix(in srgb, var(--warn) 80%, var(--ink)); }
.badge.err { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.badge.info { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
#nav .badge.err { background: var(--danger); color: #fff; }
.badge.ping { animation: ping-badge .9s var(--ease) 2; }
.tag { display: inline-block; padding: 1px 8px; margin: 1px 3px 1px 0; border-radius: 6px; background: color-mix(in srgb, var(--violet) 13%, transparent); color: var(--violet); font-size: 11.5px; font-weight: 500; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; background: var(--line-strong); vertical-align: 1px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 2.2s infinite; }
.dot.off { background: var(--danger); box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 60%, transparent); animation: pulse 1.4s infinite; }

/* ---- Thanh %, dong ho tron, sparkline, thanh uptime ---- */
.bar { height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; min-width: 60px; margin-top: 4px; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, color-mix(in srgb, var(--ok) 70%, #fff), var(--ok)); transform-origin: left; animation: grow .7s var(--ease); transition: width .6s var(--ease); }
.bar.warn > i { background: linear-gradient(90deg, color-mix(in srgb, var(--warn) 70%, #fff), var(--warn)); }
.bar.err > i { background: linear-gradient(90deg, color-mix(in srgb, var(--danger) 70%, #fff), var(--danger)); }
.gauge { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); }
.gauge svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.gauge .track { stroke: var(--surface-2); }
.gauge .val { stroke: var(--ok); stroke-linecap: round; transition: stroke-dashoffset .8s var(--ease); animation: gauge-in 1s var(--ease); }
.gauge.warn .val { stroke: var(--warn); } .gauge.err .val { stroke: var(--danger); }
.gauge .gv { margin-top: -44px; margin-bottom: 18px; font-size: 13px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.spark { display: block; width: 100%; height: 34px; margin-top: 6px; overflow: visible; }
.spark path.line { fill: none; stroke-width: 1.8; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-dasharray: 400; animation: draw 1.1s var(--ease); }
.delta { font-size: 11.5px; font-weight: 600; }
.delta.up { color: var(--danger); } .delta.down { color: var(--ok); }
.ubar { display: flex; gap: 2px; margin-top: 6px; height: 22px; align-items: stretch; max-width: 460px; }
.ubar i { flex: 1; border-radius: 2px; background: var(--line); transition: transform .12s; transform-origin: bottom; animation: rise .5s var(--ease) backwards; }
.ubar i.ok { background: var(--ok); } .ubar i.err { background: var(--danger); }
.ubar i:hover { transform: scaleY(1.25); }

/* ---- Modal, hop xac nhan, Ctrl+K ---- */
.modal, .overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, .48); backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 48px 16px; overflow-y: auto; animation: fade .18s; }
.modal.closing, .overlay.closing { animation: fade-out .16s forwards; }
.modal .box, .overlay .box { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: 100%; max-width: 640px; box-shadow: var(--shadow-lg); animation: pop .22s var(--ease); }
.modal.closing .box, .overlay.closing .box { animation: pop-out .16s forwards; }
.modal .box.wide { max-width: 920px; }
.modal h3, .overlay h3 { margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; flex-wrap: wrap; }
#dialog { z-index: 70; align-items: center; }
#dialog .box { max-width: 460px; }
#dialog .box.danger { border-top: 4px solid var(--danger); }
#dialog .dz { display: flex; gap: 12px; }
#dialog .dz .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
#dialog .box.danger .dz .ic { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
#dialog .msg { white-space: pre-wrap; color: var(--muted); margin: 0; }
#dialog .need b { font-family: var(--mono); color: var(--ink); }
#palette { z-index: 80; padding-top: 12vh; }
#palette .box { max-width: 600px; padding: 0; overflow: hidden; }
#palette .pin { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#palette .pin input { border: none; box-shadow: none; padding: 4px 0; font-size: 15px; background: transparent; }
#palette ul { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow-y: auto; }
#palette li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
#palette li .sub { margin-left: auto; font-size: 11.5px; color: var(--muted); }
#palette li.sel { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
#palette .hint { padding: 8px 16px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); display: flex; gap: 14px; }

/* ---- Toast ---- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 90; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--ok); padding: 12px 14px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; animation: toast-in .3s var(--ease); }
.toast.err { border-left-color: var(--danger); } .toast.err svg { color: var(--danger); } .toast svg { color: var(--ok); margin-top: 2px; }
.toast.out { animation: toast-out .25s forwards; }
.toast .tbar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: currentColor; opacity: .15; transform-origin: left; animation: shrink var(--d, 3.5s) linear forwards; }
#toast { display: none !important; }

/* ---- Terminal ---- */
.term { border-radius: 12px; overflow: hidden; border: 1px solid #1e293b; margin-top: 8px; background: #0b1020; }
.term .th { display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: #111827; color: #94a3b8; font-size: 11.5px; }
.term .th i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.term .th button { margin-left: auto; min-height: 24px; padding: 2px 8px; font-size: 11px; background: #1f2937; color: #cbd5e1; border: 1px solid #334155; box-shadow: none; }
pre.out { background: #0b1020; color: #d1e7ff; padding: 12px 14px; margin: 0; overflow: auto; max-height: 440px; font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-all; }

/* ---- Tab ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; color: var(--muted); border-radius: 8px 8px 0 0; border-bottom: 2px solid transparent; box-shadow: none; font-weight: 500; }
.tabs button:hover { background: var(--surface-2); color: var(--ink); box-shadow: none; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.chartbox { position: relative; height: 220px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button { background: none; color: var(--muted); min-height: 28px; padding: 2px 10px; box-shadow: none; border-radius: 8px; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---- The VPS (dang the) ---- */
.vcard { cursor: pointer; margin: 0; }
.vcard .top { display: flex; align-items: center; gap: 6px; }
.vcard .top b { font-size: 15px; }
.vcard .gauges { display: flex; justify-content: space-around; margin: 12px 0 4px; }
.vcard .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 6px; }

/* ---- Skeleton + hieu ung trang ---- */
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: 8px; }
.sk-line { height: 12px; margin: 8px 0; }
.sk-title { height: 26px; width: 220px; margin-bottom: 18px; }
.sk-card { height: 92px; border-radius: var(--radius-lg); }
.sk-block { height: 260px; border-radius: var(--radius-lg); margin-top: 16px; }
#main.enter > * { animation: page-in .38s var(--ease) backwards; }
#main.enter > *:nth-child(2) { animation-delay: .04s; } #main.enter > *:nth-child(3) { animation-delay: .08s; } #main.enter > *:nth-child(4) { animation-delay: .12s; } #main.enter > *:nth-child(n+5) { animation-delay: .16s; }
#main.enter .kpi > .card { animation: page-in .45s var(--ease) backwards; }
#main.enter .kpi > .card:nth-child(2) { animation-delay: .05s; } #main.enter .kpi > .card:nth-child(3) { animation-delay: .1s; } #main.enter .kpi > .card:nth-child(4) { animation-delay: .15s; } #main.enter .kpi > .card:nth-child(n+5) { animation-delay: .2s; }
#main.refreshing *, #main.refreshing *::before, #main.refreshing *::after { animation: none !important; transition: none !important; }
.flash { animation: flash 1.4s var(--ease); border-radius: 6px; }

@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(6px) scale(.97); } }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes rise { from { transform: scaleY(0); } }
@keyframes draw { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }
@keyframes gauge-in { from { stroke-dashoffset: 163.4; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes ping-badge { 50% { transform: scale(1.35); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); height: 0; padding: 0; margin: 0; } }
@keyframes shrink { to { transform: scaleX(0); } }
@keyframes flash { 0% { background: color-mix(in srgb, var(--brand) 28%, transparent); } 100% { background: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
}

/* Bang chinh tren tong quan rong 2 cot; ten trong bang khong bi be dong */
.grid.two > .span2 { grid-column: span 2; }
@media (max-width: 1100px) { .grid.two > .span2 { grid-column: auto; } }
td > b, td > a > b { white-space: nowrap; }
.card h3 svg.lucide { color: var(--muted); }
.copybox button { white-space: nowrap; flex-shrink: 0; }
.copybox input[type=password] { font-family: var(--font); font-size: 14px; letter-spacing: .2em; }
