:root{
  --bg:#f8fafc;
  --surface:#ffffff;
  --ink:#0f172a;
  --muted:#64748b;
  --line:#e2e8f0;
  --accent:#2563eb;
  --accent-2:#1d4ed8;
  --good:#16a34a;
  --bad:#dc2626;
  --row-alt:#f1f5fb;
  --table-header:#edf2fb;
}

*{box-sizing:border-box}
html,body{height:100%}
body{margin:0; background:var(--bg); color:var(--ink); font:14px/1.45 ui-sans-serif,system-ui,Segoe UI,Roboto,Ubuntu;}

.layout{display:grid; grid-template-columns: 260px 1fr; min-height:100vh;}
.sidebar{background:var(--surface); border-right:1px solid var(--line); display:flex; flex-direction:column; padding:16px;}
.brand{display:flex; align-items:center; gap:10px; padding:8px 0 16px 0;}
.logo{width:36px;height:36px;border-radius:10px;background:linear-gradient(180deg,#e5edff,#dbe7fe);display:grid;place-items:center;font-weight:800;color:#1e3a8a}
.title{font-weight:700}
.menu{display:flex; flex-direction:column; gap:4px; margin-top:6px;}
.item{padding:10px 12px; border-radius:10px; color:var(--ink); text-decoration:none; cursor:pointer;}
.item.active, .item:hover{background:#eef2ff; color:#1e3a8a}
.sep{height:1px;background:var(--line); margin:10px 0}
.footer{margin-top:auto; color:var(--muted); font-size:12px}

.main{display:flex; flex-direction:column; min-width:0}
.topbar{display:flex; justify-content:space-between; align-items:center; gap:12px; padding:14px 18px; border-bottom:1px solid var(--line); background:var(--surface); position:sticky; top:0; z-index:5}
.crumbs{font-weight:600}
.session{display:flex; gap:10px; align-items:center}
.ghost{background:transparent; border:1px solid var(--line); color:var(--ink); padding:8px 10px; border-radius:10px; cursor:pointer}
.ghost:hover{border-color:var(--accent)}

.content{padding:18px; display:block; min-width:0}
.tab{display:none}
.tab.active{display:block}

.grid3{display:grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap:16px}
.grid2{display:grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap:16px}
.card{background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:16px; box-shadow: 0 1px 2px rgba(15,23,42,.04);}
.card-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:10px}
.narrow{max-width:480px; margin:0 auto}
.pad-top{margin-top:10px}

.stat .label{color:var(--muted); font-size:12px}
.stat .value{font-size:24px; font-weight:700; margin-top:4px}

.primary{background:linear-gradient(180deg,#e8eefc,#d9e6fb); border:1px solid #c7d2fe; color:#0f172a; padding:8px 12px; border-radius:10px; cursor:pointer; font-weight:600}
.primary:hover{background:linear-gradient(180deg,#dbe7fd,#cfe0fd)}

.form{display:grid; gap:12px}
.form label{display:flex; flex-direction:column; gap:6px; color:var(--muted)}
input, select{padding:10px; border-radius:10px; border:1px solid var(--line); background:#fff; color:#1e3a8a}
input:focus, select:focus{outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(37,99,235,.1)}
.checkbox{display:flex; align-items:center; gap:8px}
.actions{display:flex; justify-content:flex-end; gap:8px}

.table{border:1px solid var(--line); border-radius:12px; overflow:hidden}
.table .row{display:grid; grid-template-columns: 1fr auto; gap:8px; padding:12px 14px; border-bottom:1px solid var(--line)}
.table .row:last-child{border-bottom:none}
.row .meta{color:var(--muted); font-size:12px}

.calendar{display:grid; grid-template-columns: repeat(7,1fr); gap:8px}
.day{border:1px solid var(--line); border-radius:10px; padding:8px; min-height:90px; background:#fff}
.date{font-size:12px; color:var(--muted)}
.pnl-pos{color:var(--good)} .pnl-neg{color:var(--bad)}

.code{background:#0b1220; color:#d1e9ff; padding:12px; border-radius:10px; overflow:auto}

.modal{position:fixed; inset:0; display:none; align-items:center; justify-content:center; background:rgba(2,6,23,.4); z-index:50}
.modal.show{display:flex}
.dialog{background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:16px; width:min(560px, 92vw)}
.dialog-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:10px}

.small{font-size:12px}
.muted{color:var(--muted)}

/* --- Best Table Styles --- */

.best-table {
  width: 100%;
  overflow-x: auto;
  margin-top: 8px;
}

.best-table table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15,23,42,.06);
  border: 1px solid var(--line);
}

.best-table th, .best-table td {
  padding: 12px 10px;
  text-align: left;
  font-size: 14px;
}

.best-table thead th {
  background: var(--table-header);
  font-weight: 600;
  color: var(--ink)
}

.best-table tbody tr:nth-child(even) {
  background: var(--row-alt);
}

.best-table tr:hover {
  background: #e8eefc;
}

.best-table td.actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  border: none;
  background: transparent;
  color: var(--accent-2);
  padding: 0 6px;
  font-size: 16px;
  cursor: pointer;
  transition: color 0.15s;
}
.btn-action:hover { color: var(--bad); }
.btn-action.edit:hover { color: var(--good); }

@media (max-width: 1020px){
  .layout{grid-template-columns: 72px 1fr}
  .title{display:none}
  .item{padding:10px}
  .grid3{grid-template-columns: 1fr}
  .grid2{grid-template-columns: 1fr}
  .best-table table, .best-table th, .best-table td {
    font-size: 12px;
    padding: 8px 5px;
  }
}
