:root {
  --bg: #090c14; --panel: #121827; --panel2: #0e1320; --border: #1f2a3d; --text: #e8ecf4; --muted: #8b97ad;
  --accent: #6366f1; --accent2: #8b5cf6; --green: #10b981; --red: #ef4444; --orange: #f59e0b; --blue: #3b82f6;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Manrope', system-ui, sans-serif; font-size: 14px; }
.hidden { display: none !important; }
a { color: #818cf8; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--panel2); border-right: 1px solid var(--border); padding: 14px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { font-size: 19px; font-weight: 800; color: #a78bfa; padding: 6px 8px 16px; display: flex; gap: 8px; align-items: center; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 10px; color: #b8c2d6; background: none; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; text-align: left; margin-bottom: 2px; }
.nav-item i { width: 18px; text-align: center; color: #94a3b8; }
.nav-item:hover { background: #151c2e; }
.nav-item.active { background: #1b2140; border-color: #3a4180; color: #fff; }
.nav-item.active i { color: #a5b4fc; }
.logout { margin-top: auto; color: #94a3b8; }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
h1 { font-size: 24px; margin: 0 0 2px; font-weight: 800; }
.page-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card h2 i { color: #a5b4fc; }
.grid { display: grid; gap: 14px; }
.g6 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; justify-content: space-between; gap: 10px; min-height: 96px; }
.stat .lbl { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: #aab4c8; font-weight: 700; margin-bottom: 6px; }
.stat .val { font-size: 24px; font-weight: 800; }
.stat .sub { font-size: 11px; margin-top: 4px; color: var(--muted); }
.stat .ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; }
.mini { background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.mini .lbl { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: #aab4c8; font-weight: 700; }
.mini .val { font-size: 18px; font-weight: 800; margin-top: 4px; }
.up { color: var(--green); } .down { color: var(--red); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: #8e9ab2; font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th.sortable { cursor: pointer; } th.sortable:hover { color: #fff; }
td { padding: 11px 12px; border-bottom: 1px solid #172034; vertical-align: middle; }
tr:hover td { background: #141b2c; }
td.num { font-variant-numeric: tabular-nums; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: #0b1020; padding: 2px 6px; border-radius: 6px; color: #c7d2fe; }
.empty { text-align: center; color: var(--muted); padding: 26px; }
.thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; background: #1b2236; vertical-align: middle; margin-right: 10px; flex-shrink: 0; }
.cell-flex { display: flex; align-items: center; }

/* controls */
input, select, textarea { background: #0b1120; border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 9px 12px; font: inherit; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #5457d6; }
textarea { resize: vertical; min-height: 70px; }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
label.f { display: block; font-size: 11.5px; color: #aab4c8; font-weight: 600; margin-bottom: 5px; }
.field { margin-bottom: 13px; }
.hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; cursor: pointer; }
.btn { background: #1a2236; border: 1px solid var(--border); color: var(--text); padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 700; font-size: 12.5px; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; white-space: nowrap; }
.btn:hover { filter: brightness(1.18); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }
.btn-green { background: var(--green); border-color: transparent; color: #04140e; }
.btn-red { background: var(--red); border-color: transparent; color: #fff; }
.btn-blue { background: #2563eb; border-color: transparent; color: #fff; }
.btn-orange { background: transparent; color: var(--orange); border-color: #7a5316; }
.btn-sm { padding: 6px 9px; font-size: 12px; border-radius: 8px; }
.btn-ico { padding: 7px 9px; border-radius: 8px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.b-green { background: #0d2e25; color: #34d399; border: 1px solid #14543f; }
.b-purple { background: #231a47; color: #a78bfa; border: 1px solid #4a3a94; }
.b-gray { background: #1a2133; color: #9aa6bd; border: 1px solid #2a354d; }
.b-red { background: #351618; color: #f87171; border: 1px solid #6b2328; }
.b-orange { background: #33250a; color: #fbbf24; border: 1px solid #6b4a12; }
.b-blue { background: #0f2347; color: #60a5fa; border: 1px solid #1e3f7a; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { background: #131a2b; border: 1px solid var(--border); color: #b8c2d6; padding: 7px 14px; border-radius: 9px; font: inherit; font-weight: 700; font-size: 12.5px; cursor: pointer; }
.tab.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 14px; color: var(--muted); font-size: 12.5px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=text], .toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; min-width: 140px; }

/* model price cards */
.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.mcard { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.mcard .t { display: flex; justify-content: space-between; color: #818cf8; font-weight: 700; font-size: 13px; margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(2, 5, 12, .72); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; backdrop-filter: blur(2px); }
.overlay.side { justify-content: flex-end; align-items: stretch; padding: 0; }
.modal { background: #101626; border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal.wide { max-width: 640px; }
.side .modal { border-radius: 0; max-height: none; height: 100%; max-width: 400px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.x { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kv > div { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.kv .k { font-size: 10.5px; color: #9aa6bd; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; font-weight: 700; }
.kv .v { font-weight: 700; font-size: 14px; }
.box { background: #0f1530; border: 1px solid #2a3166; border-radius: 12px; padding: 12px; margin: 12px 0; }
.stack > .btn { width: 100%; justify-content: center; margin-bottom: 8px; }

.drop { border: 1.5px dashed #2d3955; border-radius: 12px; padding: 24px; text-align: center; cursor: pointer; color: #b8c2d6; }
.drop:hover { border-color: #5457d6; }
.drop i { font-size: 26px; color: #6366f1; margin-bottom: 8px; }
.previews { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.previews div { position: relative; }
.previews img { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; }
.previews button { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; border: none; border-radius: 50%; width: 18px; height: 18px; cursor: pointer; font-size: 10px; }
.progress { height: 10px; background: #0b1120; border-radius: 8px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--green), #34d399); transition: width .4s; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #172036; border: 1px solid var(--border); border-left: 4px solid var(--green); padding: 11px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: in .2s; max-width: 360px; }
.toast.err { border-left-color: var(--red); }
@keyframes in { from { transform: translateY(10px); opacity: 0; } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 30px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.err { color: #f87171; font-size: 12.5px; min-height: 16px; }

.chart-box { height: 340px; position: relative; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 40%); padding: 20px 0 0; display: flex; justify-content: flex-end; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .sidebar .logo { width: 100%; padding-bottom: 6px; }
  #nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-item { width: auto; padding: 7px 10px; }
  .main { padding: 16px 14px 60px; }
  .two { grid-template-columns: 1fr; }
}
