:root{
  --bg: #f5f7fb;
  --card: #ffffff;
  --line: rgba(15, 23, 42, 0.10);
  --text: #0f172a;
  --muted:#64748b;

  --primary:#2563eb;
  --primary2:#1d4ed8;

  --shadow: 0 10px 30px rgba(2, 6, 23, .08);
  --radius: 16px;

  /* EXACT HEX to match Google Sheet palette */
  --l1:#FFCDCD;  /* L1 header cols */
  --l1b:#FF0000; /* L1 bar */
  --l2:#FFFFE1;  /* L2 header cols */
  --l2b:#FFFF00; /* L2 bar */
  --l3:#D9F2D9;  /* L3 header cols */
  --l3b:#00B050; /* L3 bar */
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar{
  position: sticky;
  top:0;
  z-index: 100;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding: 14px 18px;
  background: rgba(245,247,251,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width: 260px;
}
.dot{
  width:10px;
  height:10px;
  border-radius:50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .15);
}
.title{ font-weight: 700; letter-spacing:.2px; }
.meta{ font-size:12px; color: var(--muted); margin-top:2px; }

.actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn{
  border:1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
  cursor:pointer;
  box-shadow: 0 1px 0 rgba(2,6,23,.02);
}
.btn:hover{ box-shadow: 0 6px 18px rgba(2,6,23,.07); }
.btn:disabled{ opacity:.55; cursor:not-allowed; }

.btn.primary{
  background: var(--primary);
  border-color: rgba(37,99,235,.35);
  color:white;
}
.btn.primary:hover{ background: var(--primary2); }

.toggle{
  display:flex;
  align-items:center;
  gap:8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  color: var(--muted);
}

.badge{
  display:inline-flex;
  align-items:center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}
.badge.editor{ border-color: rgba(37,99,235,.35); color: #1d4ed8; }
.badge.admin{ border-color: rgba(16,185,129,.35); color: #047857; }

.menuWrap{ display:flex; align-items:center; gap:10px; position:relative; }
.caret{ font-size:12px; opacity:.75; }

.menu{
  width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.menuTitle{
  font-weight: 800;
  margin: 4px 0 10px;
  color: #1f2937;
}
.menuField{ margin-bottom: 10px; }
.menuRow{ display:flex; gap:10px; align-items:center; margin-top: 6px; }
.menuHint{ font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.35; }
.menuSection{ margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

.linkBtn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration:none;
  background: var(--bg);
}

.filters{
  padding: 12px 18px 0;
}
.filtersRow{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap: wrap;
}
.select, .input{
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 14px;
  outline:none;
  min-width: 220px;
}
.input.grow{
  flex:1;
  min-width: 320px;
}
.input::placeholder{ color: #94a3b8; }

.main{
  padding: 12px 18px 18px;
  height: calc(100vh - 132px);
}
.tableWrap{
  height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 8px 24px rgba(2,6,23,.06);
  overflow: auto; /* horizontal + vertical scroll */
}

/* Tabulator light tuning */
.tableWrap .tabulator{
  border: none;
  background: transparent;
}
.tableWrap .tabulator .tabulator-header{
  background: #f1f5f9;
  border-bottom: 1px solid var(--line);
}
.tableWrap .tabulator .tabulator-header .tabulator-col{
  background: transparent;
  border-right: 1px solid rgba(15,23,42,.06);
}

/* Header wrap text + comfortable height (mirip Google Sheet) */
.tableWrap .tabulator .tabulator-header .tabulator-col .tabulator-col-content{
  padding: 8px 10px !important;
  height: auto !important;
  min-height: 56px;
  display: flex;
  align-items: flex-start;
}
.tableWrap .tabulator .tabulator-header .tabulator-col .tabulator-col-title-holder{
  height: auto !important;
}
.tableWrap .tabulator .tabulator-header .tabulator-col .tabulator-col-title{
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  line-height: 1.15;
}

/* Hide sorter & resize handle (tidak dipakai) */
.tabulator .tabulator-col-sorter{ display:none !important; }
.tabulator .tabulator-col-resize-handle{ display:none !important; }
.tableWrap .tabulator .tabulator-tableholder{
  background: transparent;
}

/* Compact mode */
body.compact .select,
body.compact .input{ padding: 8px 10px; border-radius: 12px; }
body.compact .btn{ padding: 7px 10px; border-radius: 10px; }
body.compact .tableWrap .tabulator-row{ min-height: 28px; }
body.compact .tableWrap .tabulator-cell{ padding-top: 4px; padding-bottom: 4px; }

/* Group header styling (L1/L2/L3) */
/* Bar (top group title) */
.tabulator .tabulator-col-group.grp-l1 .tabulator-col-group-header,
.tabulator .tabulator-col-group.grp-l1 .tabulator-col-group-header .tabulator-col-content{
  background: var(--l1b) !important;
  color: #FFFFFF !important;
}
.tabulator .tabulator-col-group.grp-l2 .tabulator-col-group-header,
.tabulator .tabulator-col-group.grp-l2 .tabulator-col-group-header .tabulator-col-content{
  background: var(--l2b) !important;
  color: #000000 !important;
}
.tabulator .tabulator-col-group.grp-l3 .tabulator-col-group-header,
.tabulator .tabulator-col-group.grp-l3 .tabulator-col-group-header .tabulator-col-content{
  background: var(--l3b) !important;
  color: #FFFFFF !important;
}

/* Column-header block area under the bar */
.tabulator .tabulator-col-group.grp-l1 .tabulator-col-group-cols{ background: var(--l1) !important; }
.tabulator .tabulator-col-group.grp-l2 .tabulator-col-group-cols{ background: var(--l2) !important; }
.tabulator .tabulator-col-group.grp-l3 .tabulator-col-group-cols{ background: var(--l3) !important; }

.tabulator .tabulator-col-group .tabulator-col-group-header{
  font-weight: 800;
  /* color is set per group above */
  border-bottom: 1px solid rgba(15,23,42,.10);
}

/* Column tinting (header only) */
.tableWrap .tabulator .tabulator-header .tabulator-col.col-l1{ background: var(--l1) !important; }
.tableWrap .tabulator .tabulator-header .tabulator-col.col-l2{ background: var(--l2) !important; }
.tableWrap .tabulator .tabulator-header .tabulator-col.col-l3{ background: var(--l3) !important; }

/* Body rows: keep clean white like Google Sheet */
.tableWrap .tabulator .tabulator-row .tabulator-cell{
  background: #FFFFFF !important;
}
.tableWrap .tabulator .tabulator-row.tabulator-row-even .tabulator-cell{
  background: #FFFFFF !important;
}

/* Row hover */
.tabulator .tabulator-row:hover .tabulator-cell{
  background: rgba(37,99,235,.06);
}

/* Responsive tweaks */
@media (max-width: 820px){
  .main{ height: calc(100vh - 162px); }
  .brand{ min-width: 0; }
  .input.grow{ min-width: 260px; }
  .select{ min-width: 180px; }
}
