.shell {
  grid-template-columns: 258px minmax(0, 1fr);
  background: #f3f6fb;
}

.sidebar {
  z-index: 10;
  padding: 24px 16px;
  border-right: 1px solid #17243a;
  background:
    radial-gradient(circle at 0 0, rgba(38, 105, 235, .16), transparent 34%),
    linear-gradient(180deg, #07111f, #0b1628 58%, #07111f);
  box-shadow: 12px 0 36px rgba(15, 35, 70, .08);
}

.sidebar .brand {
  min-height: 58px;
  margin-bottom: 18px;
  padding: 8px 12px 22px;
  border-bottom: 1px solid rgba(132, 164, 214, .16);
  color: #fff;
  font-size: 18px;
  letter-spacing: .12em;
}

.sidebar .brand img { width: 58px; height: 34px; }
.sidebar button {
  min-height: 46px;
  align-items: center;
  margin: 6px 0;
  padding: 0 15px;
  border: 1px solid transparent;
  color: #9dacbf;
  font-size: 14px;
  font-weight: 700;
  transition: .18s ease;
}
.sidebar button:hover {
  border-color: rgba(75, 131, 230, .2);
  background: rgba(42, 91, 177, .14);
  color: #eaf2ff;
  transform: translateX(2px);
}
.sidebar button.active {
  border-color: rgba(73, 132, 240, .42);
  background: linear-gradient(90deg, rgba(35, 91, 196, .42), rgba(32, 72, 139, .16));
  color: #fff;
  box-shadow: inset 3px 0 #4b91ff, 0 8px 22px rgba(0, 29, 83, .2);
}
.sidebar #logout { margin-top: 28px; color: #8190a5; }

.content {
  width: min(100%, 1680px);
  margin: 0 auto;
  padding: 38px 42px 70px;
}
.topbar {
  min-height: 70px;
  gap: 24px;
  margin-bottom: 24px;
}
.topbar h1 {
  color: #101c32;
  font-size: clamp(26px, 2vw, 34px);
  letter-spacing: -.03em;
}
.topbar small { display: block; margin-top: 7px; color: #77849a; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.primary,.secondary,.danger {
  min-height: 42px;
  padding: 0 17px;
  border-radius: 10px;
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.primary { background: linear-gradient(135deg, #2463df, #1246bd); box-shadow: 0 8px 18px rgba(30, 86, 203, .2); }
.secondary { border: 1px solid #d6e2f5; background: #f7faff; }
.primary:hover,.secondary:hover,.danger:hover { transform: translateY(-1px); filter: brightness(1.03); }

.cards { gap: 14px; margin-bottom: 22px; }
.stat {
  position: relative;
  min-height: 116px;
  overflow: hidden;
  padding: 22px;
  border-color: #dfe7f2;
  border-radius: 15px;
  background: linear-gradient(145deg, #fff, #f8faff);
  box-shadow: 0 8px 28px rgba(35, 65, 110, .06);
}
.stat::after {
  position: absolute;
  width: 88px;
  height: 88px;
  right: -30px;
  bottom: -38px;
  content: "";
  border-radius: 50%;
  background: rgba(39, 100, 235, .07);
}
.stat span { color: #718097; font-weight: 650; }
.stat b { position: relative; z-index: 1; margin-top: 12px; color: #14213a; font-size: 27px; letter-spacing: -.02em; }
.stat b small { color: #8793a6; font-size: 13px; font-weight: 650; }

.panel {
  margin: 16px 0;
  padding: 24px;
  border-color: #dfe6f0;
  border-radius: 17px;
  box-shadow: 0 10px 32px rgba(28, 55, 94, .055);
}
.panel-head { min-height: 44px; margin-bottom: 16px; }
.panel-head h2 { color: #17233a; font-size: 20px; }
.panel-head .muted { padding: 5px 10px; border-radius: 99px; background: #f0f4fa; font-size: 12px; }

.grid2,.grid3 { gap: 0 14px; }
.grid4 { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:0 14px; }
.field { gap: 7px; margin: 13px 0; color: #43516a; font-size: 12px; }
.field input,.field textarea,.field select,.compact-input {
  min-height: 44px;
  border-color: #dce4ef;
  border-radius: 10px;
  background: #fbfcfe;
}
.field input:hover,.field textarea:hover,.field select:hover,.compact-input:hover { border-color: #b9cae4; }

.table-wrap {
  margin: 8px -24px -24px;
  border-top: 1px solid #e7ecf3;
  border-radius: 0 0 17px 17px;
}
table { min-width: 980px; }
th,td { height: 58px; padding: 12px 16px; border-color: #edf1f6; }
th { position: sticky; top: 0; z-index: 1; background: #f7f9fc; color: #69778d; font-size: 12px; letter-spacing: .02em; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #f7faff; }
td { color: #344159; font-size: 13px; }
td a { color: #276be6; }
.tag { padding: 6px 10px; font-size: 11px; }

.tabs { gap: 6px; padding: 4px; border-radius: 12px; background: #f1f4f8; }
.tabs button { margin: 0; background: transparent; }
.tabs button.active { box-shadow: 0 5px 13px rgba(39, 100, 235, .2); }
.detail { padding: 15px; border: 1px solid #e5eaf1; background: #f8fafe; }
.notice { border: 1px solid #dbe7fb; }

.modal {
  padding: 28px;
  background: rgba(3, 10, 24, .72);
  backdrop-filter: blur(8px);
}
.modal-card {
  padding: 28px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 20px;
  box-shadow: 0 30px 90px rgba(0, 18, 52, .32);
}
.modal-title { gap: 18px; margin-bottom: 14px; }
.modal-title h2 { color: #152139; }
.close { transition: transform .15s ease, background .15s ease; }
.close:hover { background: #e5ebf5; transform: rotate(5deg) scale(1.05); }
.actions { padding-top: 16px; border-top: 1px solid #edf0f5; }

.report-filter {
  min-height: 82px;
  margin-bottom: 22px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #dfe6f0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 7px 24px rgba(28, 55, 94, .045);
}
.report-presets { display: flex; overflow: hidden; border: 1px solid #dbe4f1; border-radius: 10px; background: #fff; }
.report-presets button { min-width: 52px; height: 40px; border: 0; border-right: 1px solid #dbe4f1; background: transparent; color: #53647e; font-weight: 800; }
.report-presets button:last-child { border-right: 0; }
.report-presets button.active { background: #2764eb; color: #fff; box-shadow: 0 5px 12px rgba(39,100,235,.22); }
.report-date-range { min-height: 42px; padding: 0 11px; display: flex; align-items: center; gap: 9px; border: 1px solid #dbe4f1; border-radius: 10px; background: #fff; }
.report-date-range svg { width: 18px; fill: none; stroke: #2871ed; stroke-width: 2; stroke-linecap: round; }
.report-date-range span { color: #53647e; font-size: 13px; font-weight: 700; }
.report-date-range input { width: 145px; height: 38px; padding: 0 4px; border: 0; outline: 0; background: transparent; color: #26354e; font: inherit; font-size: 14px; font-weight: 700; }
.master-finance-cards .stat { border-top: 3px solid #2764eb; }
.master-finance-cards .finance-in { border-top-color: #18a66a; }
.master-finance-cards .finance-out { border-top-color: #e45858; }
.master-finance-cards .finance-preset { border-top-color: #9867e8; }
.master-finance-cards .finance-rake { border-top-color: #e6a52e; }
.dashboard-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.dashboard-summary>div { padding: 13px 16px; border: 1px solid #e5eaf1; border-radius: 11px; background: #f8fafe; }
.dashboard-summary span,.finance-balance-preview span { display: block; color: #7b8799; font-size: 12px; }
.dashboard-summary b,.finance-balance-preview b { display: block; margin-top: 6px; color: #26354d; }
.finance-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.finance-actions button { min-height: 36px; padding: 0 13px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid transparent; border-radius: 9px; font-size: 12px; font-weight: 800; cursor: pointer; box-shadow: 0 4px 10px rgba(29,54,91,.08); transition: transform .15s ease,box-shadow .15s ease,filter .15s ease; }
.finance-actions button:hover { transform: translateY(-1px); filter: brightness(.98); box-shadow: 0 7px 16px rgba(29,54,91,.14); }
.finance-actions button:active { transform: translateY(0) scale(.97); }
.finance-actions button span { font-size: 15px; line-height: 1; }
.finance-recharge { border-color: #a9e5c9!important; background: linear-gradient(180deg,#f3fff9,#e7f9f0); color: #0d8453; }
.finance-deduct { border-color: #f0bfc2!important; background: linear-gradient(180deg,#fff8f8,#ffeded); color: #c43d45; }
.finance-test { border-color: #cbbcf1!important; background: linear-gradient(180deg,#fbf9ff,#f0eaff); color: #6845c1; }
.detail-finance-actions { margin: 0 0 22px; padding-bottom: 20px; border-bottom: 1px solid #e7ecf3; }
.detail-finance-actions button { min-height: 40px; padding: 0 15px; }
.test-balance { color: #7452c7; font-weight: 750; }
.finance-modal { width: min(520px,100%); }
.finance-balance-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.finance-balance-preview>div { padding: 13px; border: 1px solid #e1e8f2; border-radius: 10px; background: #f8fafe; }
.ledger-filters { margin-bottom: 10px; }
.ledger-recharge { background: #e5f8ef; color: #148455; }
.ledger-deduct { background: #fff0f0; color: #c14343; }
.ledger-test_add,.ledger-test_clear { background: #f1ebff; color: #7250bd; }
td.positive { color: #13905b; font-weight: 800; }
td.negative { color: #d04444; font-weight: 800; }
td small { display: block; margin-top: 3px; color: #8a95a7; }
.empty-ledger { padding: 50px!important; color: #8995a6; text-align: center; }
.preset-isolation-notice { margin-bottom: 18px; border-color: #cbd8ee; background: #f4f8ff; color: #49617f; }
.preset-editor { margin-bottom: 18px; }
.preset-editor textarea { width: 100%; resize: vertical; }
.preset-hands { margin-top: 12px; }
.fixed-hand.hidden { display: none; }
.range-hand { display: none; }
.range-hand.show { display: grid; }
.preset-row-actions { display: flex; gap: 8px; white-space: nowrap; }
.preset-row-actions button { min-height: 34px; padding: 7px 13px; }
.preset-save-row,.preset-batch-actions { display: flex; align-items: center; gap: 10px; }
.preset-save-row { margin-top: 14px; justify-content: flex-end; }
.preset-save-row small { margin-right: auto; color: #7d899b; }
.preset-batch-actions button { min-height: 36px; padding: 0 14px; border: 1px solid; border-radius: 9px; font-weight: 800; cursor: pointer; }
.silent-switch { display: inline-flex; cursor: pointer; }
.silent-switch input { position: absolute; opacity: 0; pointer-events: none; }
.silent-switch span { width: 42px; height: 23px; padding: 3px; display: block; border-radius: 999px; background: #aeb7c5; transition: background .18s ease; }
.silent-switch span:after { content: ''; width: 17px; height: 17px; display: block; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(25,38,59,.24); transition: transform .18s ease; }
.silent-switch input:checked+span { background: #18a66a; }
.silent-switch input:checked+span:after { transform: translateX(19px); }
.row-switch span { width: 38px; height: 21px; }
.row-switch span:after { width: 15px; height: 15px; }
.row-switch input:checked+span:after { transform: translateX(17px); }
.environment-toggle { min-width: 76px; height: 32px; padding: 0 11px; border: 1px solid; border-radius: 999px; font-size: 11px; font-weight: 850; cursor: pointer; transition: transform .15s ease,box-shadow .15s ease; }
.environment-toggle:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(28,52,88,.14); }
.environment-toggle.development { border-color: #a9e5c9; background: #eaf9f2; color: #128456; }
.environment-toggle.production { border-color: #cfd7e4; background: #f2f4f7; color: #637087; }
.official-domain-list{display:grid;gap:10px;margin:16px 0}.official-domain-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:end;padding:12px 14px;border:1px solid #dfe6f0;border-radius:12px;background:#f8fafe}.official-domain-row .field{margin:0}.official-domain-row .danger{margin-bottom:1px}.add-official-domain{margin-bottom:18px}.save-instance-domains{margin-top:12px}

@media (max-width: 1100px) {
  .shell { grid-template-columns: 220px minmax(0,1fr); }
  .content { padding: 30px 24px 60px; }
  .cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .report-filter { flex-wrap: wrap; }
  .report-filter>.primary { margin-left: 0; }
}

@media (max-width: 760px) {
  .grid4 { grid-template-columns:1fr; }
  .shell { display: block; }
  .sidebar { position: relative; height: auto; padding: 10px; }
  .sidebar .brand { min-width: max-content; margin: 0 8px 0 0; padding: 6px 12px; border: 0; }
  .sidebar button { min-width: max-content; }
  .content { padding: 22px 14px 52px; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { min-height: 100px; padding: 17px; }
  .panel { padding: 18px; }
  .table-wrap { margin: 8px -18px -18px; }
  .modal { padding: 12px; }
  .modal-card { padding: 20px; }
  .report-filter { align-items: stretch; }
  .report-filter>label { width: calc(50% - 7px); display: grid; }
  .report-filter input { width: 100%; }
  .report-filter>.primary { width: 100%; }
  .dashboard-summary { grid-template-columns: 1fr 1fr; }
}
