:root {
  --bg: #0b0f16;
  --panel: #121823;
  --panel-2: #0e141d;
  --border: #253041;
  --text: #e6edf3;
  --muted: #8b97a8;
  --accent: #f5a623;
  --accent-soft: #f5a62322;
  --green: #3fb950;
  --red: #f8665c;
  --blue: #58a6ff;
  --mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 'Be Vietnam Pro', 'Segoe UI', system-ui, sans-serif;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 14px 16px 40px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.muted { color: var(--muted); }
.hl { color: var(--accent); font-weight: 600; }
.hidden { display: none !important; }

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.brand { font-size: 20px; font-weight: 700; margin: 0; }
.brand .hl { font-weight: 700; }
.status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px #3fb95033; }
.dot.off { background: var(--red); }

.btn {
  background: #1b2433; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- banner ---------- */
.banner { position: relative; padding: 12px 40px 12px 14px; margin-bottom: 14px; background: linear-gradient(90deg, #f5a62314, transparent 60%), var(--panel); }
.banner p { margin: 0; }
.banner .sub { color: var(--muted); margin-top: 4px; font-size: 13px; }
.banner .close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; }

/* ---------- stage: pet + monitor ---------- */
.stage { display: grid; grid-template-columns: 240px 1fr; gap: 16px; margin-bottom: 14px; }
.pet-box { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bubble {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 8px 14px; font-size: 12px; color: #d8c9a8; margin-bottom: 6px; position: relative; text-align: center; min-height: 36px;
}
.bubble::after, .bubble::before { content: ''; position: absolute; border-radius: 50%; border: 1px solid var(--border); background: var(--panel); }
.bubble::before { width: 12px; height: 12px; bottom: -18px; left: 46%; }
.bubble::after { width: 7px; height: 7px; bottom: -28px; left: 50%; }
.pet { width: 220px; margin-top: 18px; }
.pet-desk { width: 100%; height: 4px; background: var(--accent); border-radius: 2px; }
.pet-caption { font-size: 11px; color: var(--muted); margin-top: 6px; }

.monitor { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.screen { width: 100%; overflow: hidden; display: flex; flex-direction: column; }
.screen-bar { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.screen-bar .title { flex: 1; text-align: center; }
.lights i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.terminal {
  background: #070b11; font: 12.5px/1.75 var(--mono); padding: 10px 14px; height: 210px; overflow-y: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}
.terminal .line { white-space: pre-wrap; word-break: break-word; margin-bottom: 6px; }
.t-time { color: var(--accent); }
.t-staff { color: var(--green); }
.t-thought { color: #56d4c1; }
.t-owner { color: var(--blue); }
.t-system { color: var(--muted); }
.money-in { color: var(--accent); font-weight: 700; }
.caret { display: inline-block; width: 8px; height: 14px; background: var(--accent); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
.stand { width: 46px; height: 12px; background: #2a3344; }
.stand-base { width: 90px; height: 5px; background: #2a3344; border-radius: 3px; }

/* ---------- stats ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.card { padding: 12px 14px; }
.card .label { font-size: 12px; color: var(--muted); }
.card .value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.card .delta { font-size: 12px; color: var(--muted); }
.v-net { color: var(--accent); } .v-in { color: var(--green); } .v-out { color: var(--red); }

/* ---------- chart ---------- */
.section { padding: 12px 14px; margin-bottom: 14px; }
.section h2 { font-size: 14px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.chart { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; height: 170px; align-items: end; position: relative; }
.chart::before { content: ''; position: absolute; left: 0; right: 0; bottom: 20px; border-top: 1px solid var(--border); }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; cursor: default; }
.bar-col .bar { width: min(26px, 60%); background: var(--accent); border-radius: 4px 4px 0 0; min-height: 0; transition: height .5s ease; }
.bar-col .bar.zero { height: 1px !important; background: var(--border); }
.bar-col .val { font-size: 10px; color: var(--muted); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.bar-col .day { font-size: 10px; color: var(--muted); height: 20px; line-height: 20px; }
.bar-col.today .day { color: var(--text); font-weight: 600; }
.bar-col:hover .bar:not(.zero) { filter: brightness(1.15); }
.tip {
  position: absolute; bottom: calc(100% - 10px); left: 50%; transform: translateX(-50%); z-index: 5;
  background: #1d2533; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 11px;
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s;
}
.bar-col:hover .tip { opacity: 1; }

/* ---------- tables / lists ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.table-wrap { overflow-x: auto; max-height: 340px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid #1c2534; vertical-align: top; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--panel); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.flash td { animation: flash 2.4s ease-out; }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--border); white-space: nowrap; }
.pill.paid { color: var(--green); border-color: #3fb95066; }
.pill.pending { color: var(--accent); border-color: #f5a62366; }
.pill.partial { color: var(--blue); border-color: #58a6ff66; }
.src { font-size: 10px; color: var(--muted); }

.journal { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; font-size: 12.5px; }
.journal li { padding: 7px 0; border-bottom: 1px solid #1c2534; }
.journal li:first-child { animation: flash 2.4s ease-out; }

.product-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.p-item { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: flex; gap: 10px; }
.p-item.off { opacity: .5; }
.p-item .emoji { font-size: 28px; line-height: 1; }
.p-item .name { font-weight: 600; }
.p-item .actions { display: flex; gap: 6px; margin-top: 6px; }

/* ---------- forms / modal ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.field input, .field textarea, .field select {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 14px;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.modal-bg { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { width: min(460px, 100%); max-height: 92vh; overflow-y: auto; padding: 18px; position: relative; }
.modal h3 { margin: 0 0 12px; }
.modal .x { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: #1b2433; border: 1px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: 0 8px 24px #0008; animation: slidein .3s ease-out; }
.toast b { color: var(--accent); }

/* ---------- pet animation ---------- */
.pet-svg { width: 100%; display: block; overflow: visible; }
.pet-eyes-happy, .pet-pop, .pet-tongue { opacity: 0; }
.pet-tail { transform-origin: 176px 178px; animation: wag 1.2s ease-in-out infinite; }
.pet-eyes { transform-origin: 120px 73px; animation: eyeblink 4s infinite; }
.pet-head { transform-origin: 120px 130px; animation: bob 3s ease-in-out infinite; }
.pet-steam { animation: steam 2.4s ease-in-out infinite; }
.pet.is-typing .pet-paw-l { animation: tap .32s ease-in-out infinite; }
.pet.is-typing .pet-paw-r { animation: tap .32s ease-in-out infinite .16s; }
.pet.is-happy .pet-svg { animation: jump .6s ease-in-out 3; }
.pet.is-happy .pet-eyes { opacity: 0; }
.pet.is-happy .pet-eyes-happy, .pet.is-happy .pet-tongue { opacity: 1; }
.pet.is-happy .pet-mouth { opacity: 0; }
.pet.is-happy .pet-pop { animation: pop 1.4s ease-out 2; }
.pet.is-happy .pet-tail { animation-duration: .3s; }

@keyframes wag { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(8deg); } }
@keyframes eyeblink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes bob { 0%, 100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg); } }
@keyframes tap { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes jump { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes pop { 0% { opacity: 0; transform: translateY(10px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-24px); } }
@keyframes steam { 0%, 100% { opacity: .2; transform: translateY(2px); } 50% { opacity: .8; transform: translateY(-3px); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes flash { from { background: #f5a6232e; } to { background: transparent; } }
@keyframes slidein { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- responsive ---------- */
.stage > *, .grid-2 > *, .cards > * { min-width: 0; }

@media (max-width: 900px) {
  .stage, .grid-2, .cards { grid-template-columns: minmax(0, 1fr); }
  .pet-box { flex-direction: row; justify-content: center; gap: 12px; }
  .pet { width: 150px; }
  .pet-desk, .pet-caption { display: none; }
  .chart .val { display: none; }
  .chart .day { font-size: 9px; }
}

@media (max-width: 600px) {
  .chart .bar-col:nth-child(odd):not(.today) .day { visibility: hidden; }
}

/* Rắn Bán Rong nhìn theo (shop) */
.pet-pupils { transition: transform .25s ease-out; }
.pet-turn { transform-origin: 120px 130px; transition: transform .4s cubic-bezier(.3, 1.4, .5, 1); }


/* Rắn: lưỡi chẻ đôi thè ra thụt vào */
.pet-fork { transform-origin: 120px 104px; animation: flick 3.4s ease-in-out infinite; }
.pet.is-happy .pet-fork { opacity: 0; }
@keyframes flick { 0%, 78%, 100% { transform: scaleY(0); } 82% { transform: scaleY(1); } 86% { transform: scaleY(.4); } 90% { transform: scaleY(1); } 94% { transform: scaleY(0); } }

/* ---------- thanh cuộn tối, mảnh, bo tròn ---------- */
:root { color-scheme: dark; }
* { scrollbar-width: thin; scrollbar-color: #3a4558 transparent; } /* Firefox */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3a4558; border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-corner { background: transparent; }
.terminal::-webkit-scrollbar-thumb { background-color: #2a3446; }
.terminal::-webkit-scrollbar-thumb:hover { background-color: var(--accent); }

/* Form sản phẩm: tải ảnh/video */
.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 10px; font-size: 12px; }
.upload-row label.btn { cursor: pointer; }
.modal textarea { resize: vertical; }
