:root{
  --navy-950:#0a1f38;
  --navy-900:#0d2c54;
  --navy-800:#123a6b;
  --navy-700:#1a4a85;
  --gold-500:#c9a227;
  --gold-400:#dab949;
  --paper:#f6f4ee;
  --panel:#ffffff;
  --line:#e2ddd0;
  --ink-900:#1c2530;
  --ink-600:#54606f;
  --ink-400:#8993a1;
  --red-600:#b3261e;
  --green-700:#1e6b3c;
  --radius:10px;
  --shadow-sm:0 1px 2px rgba(13,44,84,0.06), 0 1px 1px rgba(13,44,84,0.04);
  --shadow-md:0 6px 20px rgba(13,44,84,0.10);
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--paper);
  color:var(--ink-900);
  font-family:'Public Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  font-size:14px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
a{color:inherit;}

/* ===== Shell layout: sidebar + topheader + content + footer ===== */
.seal{
  width:44px;height:44px;border-radius:50%;
  background:radial-gradient(circle at 32% 28%, var(--gold-400), var(--gold-500) 55%, #8a6c14 100%);
  display:flex;align-items:center;justify-content:center;
  font-family:'Lora', serif; font-weight:700; font-size:13px; color:var(--navy-950);
  border:2px solid rgba(255,255,255,0.55);
  flex:none;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.15);
}

.app-shell{display:flex; min-height:100vh;}

/* --- Sidebar --- */
.sidebar{
  width:264px; flex:none;
  background:linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
  color:#fff;
  border-right:3px solid var(--gold-500);
  position:fixed; top:0; left:0; bottom:0;
  display:flex; flex-direction:column;
  overflow-y:auto;
  z-index:50;
}
.sidebar-brand{
  display:flex; align-items:center; gap:12px;
  padding:22px 20px 20px;
  border-bottom:1px solid rgba(255,255,255,0.1);
}
.sidebar-brand .brandtext h1{font-family:'Lora', serif; font-weight:600; font-size:16px; margin:0; line-height:1.25;}
.sidebar-brand .brandtext h1 a{text-decoration:none; color:#fff;}
.sidebar-brand .brandtext p{margin:4px 0 0; font-size:10.5px; color:#c7d4e8; letter-spacing:.3px; line-height:1.4;}

.sidebar-nav{padding:16px 12px; flex:1;}
.sidebar-nav-label{font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.7px; color:#7f93b3; padding:6px 12px 10px;}
.nav-link{
  display:flex; align-items:center; gap:11px;
  color:#c7d4e8; text-decoration:none;
  font-size:13.5px; font-weight:600; letter-spacing:.2px;
  padding:10px 12px; border-radius:8px; margin-bottom:3px;
  border-left:3px solid transparent;
}
.nav-link svg{width:17px; height:17px; flex:none;}
.nav-link:hover{color:#fff; background:rgba(255,255,255,0.06);}
.nav-link.active{color:#fff; background:rgba(255,255,255,0.09); border-left-color:var(--gold-500);}

.sidebar-foot{padding:14px 16px 18px; border-top:1px solid rgba(255,255,255,0.1);}
.sidebar-user{display:flex; align-items:center; gap:10px; font-family:inherit;}
.sidebar-user:hover .sidebar-avatar{background:rgba(255,255,255,0.2);}
.sidebar-avatar{
  width:34px; height:34px; border-radius:50%; flex:none;
  background:rgba(255,255,255,0.12); color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:13px; font-family:'Lora', serif;
}
.sidebar-user-info{min-width:0;}
.sidebar-user-name{font-size:12.5px; font-weight:600; color:#fff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.sidebar-logout{font-size:11.5px; color:#f0d98e; text-decoration:none;}
.sidebar-logout:hover{text-decoration:underline;}
.sidebar-version{font-size:10.5px; color:#7f93b3; margin-top:12px;}

.sidebar-overlay{
  display:none; position:fixed; inset:0; background:rgba(10,20,35,0.5); z-index:45;
}
.sidebar-overlay.visible{display:block;}

/* --- Main column / topheader --- */
.main-col{flex:1; min-width:0; display:flex; flex-direction:column; min-height:100vh; margin-left:264px;}

.topheader{
  background:var(--panel); border-bottom:1px solid var(--line);
  display:flex; align-items:center; gap:16px;
  padding:14px 32px; position:sticky; top:0; z-index:30;
  box-shadow:var(--shadow-sm);
}
.sidebar-toggle{
  display:none; appearance:none; background:none; border:none; cursor:pointer;
  color:var(--navy-900); padding:6px; margin:-6px; border-radius:6px;
}
.sidebar-toggle svg{width:22px;height:22px;}
.sidebar-toggle:hover{background:#f2f4f7;}

.topheader-crumb{display:flex; align-items:center; gap:7px; font-size:13px; color:var(--ink-600); min-width:0;}
.crumb-root{font-weight:600; color:var(--ink-400);}
.crumb-sep{width:13px; height:13px; flex:none; color:var(--ink-400);}
.crumb-current{font-weight:700; color:var(--navy-950); font-size:14.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}

.topheader-right{margin-left:auto; display:flex; align-items:center; gap:16px;}
.topheader-date{font-size:12px; color:var(--ink-400); white-space:nowrap;}
.topheader-user{display:flex; align-items:center; gap:8px; font-size:13px; font-weight:600; color:var(--navy-950); padding-left:14px; border-left:1px solid var(--line); font-family:inherit; border-top:none; border-right:none; border-bottom:none; cursor:pointer; border-radius:6px;}
.topheader-user:hover{color:var(--navy-700);}
.topheader-avatar{
  width:28px; height:28px; border-radius:50%; flex:none;
  background:var(--navy-900); color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:11.5px; font-family:'Lora', serif;
}

main.content{margin:0; padding:28px 32px 56px; width:100%; flex:1; min-width:0;}

.app-footer{
  border-top:1px solid var(--line); background:var(--panel);
  padding:14px 32px; font-size:11.5px; color:var(--ink-400);
  display:flex; justify-content:space-between; flex-wrap:wrap; gap:6px;
}

@media (max-width:980px){
  .sidebar{transform:translateX(-100%); transition:transform .2s ease; box-shadow:0 0 40px rgba(0,0,0,.3);}
  .sidebar.open{transform:translateX(0);}
  .main-col{margin-left:0;}
  .sidebar-toggle{display:inline-flex; align-items:center; justify-content:center;}
  .topheader-date{display:none;}
}
@media (max-width:560px){
  .topheader{padding:12px 16px;}
  main.content{padding:18px 16px 40px;}
  .app-footer{padding:12px 16px; flex-direction:column;}
  .topheader-user span{display:none;}
}

h2.section-title{font-family:'Lora', serif; font-weight:600; font-size:22px; margin:0 0 4px;color:var(--navy-950);}
.section-sub{color:var(--ink-600); font-size:13px; margin:0 0 22px;}

/* ===== Flash / banners ===== */
.flash{padding:11px 16px; border-radius:8px; margin-bottom:18px; font-size:13px; display:flex; gap:8px; align-items:center;}
.flash-success{background:#e7f5ec; color:var(--green-700); border:1px solid #bfe3cc;}
.flash-error{background:#fdecea; color:var(--red-600); border:1px solid #f3c8c3;}
.banner{
  background:#fdf6e3; border:1px solid #eddca0; color:#7a5c0a; border-radius:8px;
  padding:10px 14px; font-size:12.5px; margin-bottom:18px; display:flex; gap:8px; align-items:flex-start;
}

/* ===== Cards / dashboard ===== */
.stat-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:24px;}
@media (max-width:900px){.stat-grid{grid-template-columns:repeat(2,1fr);}}
.stat-card{
  background:var(--panel); border:1px solid var(--line); border-radius:var(--radius);
  padding:18px 20px; box-shadow:var(--shadow-sm); position:relative; overflow:hidden;
}
.stat-card::before{content:""; position:absolute; top:0; left:0; width:4px; height:100%; background:var(--navy-800);}
.stat-card.gold::before{background:var(--gold-500);}
.stat-label{font-size:11.5px; text-transform:uppercase; letter-spacing:.6px; color:var(--ink-600); font-weight:600;}
.stat-value{font-family:'Lora', serif; font-size:27px; font-weight:700; color:var(--navy-950); margin-top:6px;}
.stat-foot{font-size:12px; color:var(--ink-400); margin-top:4px;}

.panel{
  background:var(--panel); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow-sm); padding:20px 22px; margin-bottom:20px;
}
.panel h3{font-family:'Lora', serif; font-size:15.5px; margin:0 0 14px; color:var(--navy-950); font-weight:600;}

.bar-row{display:flex; align-items:center; gap:10px; margin-bottom:9px; font-size:12.5px;}
.bar-name{width:130px; flex:none; color:var(--ink-600); text-align:right; font-weight:500;}
.bar-track{flex:1; background:#eee9da; border-radius:4px; height:16px; position:relative; overflow:hidden;}
.bar-fill{position:absolute; left:0; top:0; height:100%; background:linear-gradient(90deg, var(--navy-700), var(--navy-900)); border-radius:4px;}
.bar-count{width:56px; flex:none; text-align:right; font-weight:600; color:var(--navy-950); font-variant-numeric:tabular-nums;}

.chips{display:flex; flex-wrap:wrap; gap:8px;}
.chip{background:#eef1f6; border:1px solid var(--line); border-radius:20px; padding:6px 12px; font-size:12px; color:var(--ink-600); display:flex; gap:6px; align-items:center;}
.chip b{color:var(--navy-950);}

/* ===== Toolbar / filters ===== */
.toolbar{display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-bottom:16px;}
input, select, textarea{
  font-family:inherit; font-size:13px; color:var(--ink-900);
  border:1px solid #cfd3da; border-radius:7px; padding:9px 11px; background:#fff;
}
input:focus, select:focus, textarea:focus{outline:2px solid var(--gold-500); outline-offset:1px; border-color:var(--navy-700);}
.search-input{flex:1; min-width:220px;}
select{min-width:150px;}
.btn{
  appearance:none; border:none; border-radius:7px; padding:9px 16px; font-family:inherit;
  font-size:13px; font-weight:600; cursor:pointer; display:inline-flex; align-items:center; gap:7px;
  transition:filter .12s, transform .05s; text-decoration:none;
}
.btn:active{transform:translateY(1px);}
.btn-primary{background:var(--navy-900); color:#fff;}
.btn-primary:hover{filter:brightness(1.15);}
.btn-gold{background:var(--gold-500); color:var(--navy-950);}
.btn-gold:hover{filter:brightness(1.08);}
.btn-ghost{background:#fff; color:var(--navy-900); border:1px solid #cfd3da;}
.btn-ghost:hover{background:#f2f4f7;}
.btn-danger{background:#fdecea; color:var(--red-600); border:1px solid #f3c8c3;}
.btn-danger:hover{background:#fbdfdc;}
.btn-sm{padding:6px 10px; font-size:12px;}
.btn:disabled{opacity:.45; cursor:not-allowed;}
.btn svg{width:14px;height:14px;}

.toolbar-spacer{flex:1;}
.toolbar-row{display:contents;}
.toolbar-actions{display:contents;}

@media (max-width:720px){
  .toolbar{flex-direction:column; align-items:stretch;}
  .toolbar .search-input{min-width:0; width:100%;}
  .toolbar-spacer{display:none;}
  .toolbar-row{display:flex; gap:10px; width:100%;}
  .toolbar-row select{flex:1; min-width:0;}
  .toolbar-actions{display:flex; gap:10px; width:100%;}
  .toolbar-actions .btn{flex:1; justify-content:center;}
}

/* ===== Table ===== */
.table-wrap{background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow-sm); overflow:hidden;}
.table-scroll{overflow:auto; max-height:68vh;}
table{width:100%; border-collapse:collapse; font-size:12.8px;}
.table-wrap thead th{
  background:var(--navy-900); color:#e7ecf3; text-align:left; font-weight:600;
  padding:11px 14px; font-size:11.3px; letter-spacing:.3px; text-transform:uppercase; white-space:nowrap;
  position:sticky; top:0; z-index:5;
  border-right:1px solid rgba(255,255,255,0.12);
}
.table-wrap thead th:last-child{border-right:none;}
tbody td{padding:10px 14px; border-bottom:1px solid #eee9da; border-right:1px solid #f1ede0; vertical-align:middle; white-space:nowrap;}
tbody td:last-child{border-right:none;}
tbody tr:nth-child(even){background:#faf8f2;}
tbody tr:hover{background:#f5f1e4;}
tbody tr.inactive{opacity:.5;}
.name-cell{font-weight:600; color:var(--navy-950);}
.id-cell{font-variant-numeric:tabular-nums; color:var(--ink-600); font-size:12px;}
.tag{display:inline-block; padding:3px 9px; border-radius:20px; font-size:11px; font-weight:600; background:#eef1f6; color:var(--navy-800); white-space:nowrap;}
.tag.status-active{background:#e7f5ec; color:var(--green-700);}
.tag.status-inactive{background:#f4eae8; color:var(--red-600);}
.amt{font-variant-numeric:tabular-nums; font-weight:600; color:var(--navy-950);}
.row-actions{display:flex; gap:6px; justify-content:flex-end;}
.icon-btn{
  border:1px solid #d9dde3; background:#fff; border-radius:6px; width:28px; height:28px;
  display:inline-flex; align-items:center; justify-content:center; cursor:pointer; color:var(--ink-600);
  text-decoration:none;
}
.icon-btn:hover{background:#f2f4f7; color:var(--navy-900);}
.icon-btn svg{width:14px;height:14px;}
.icon-btn.danger:hover{background:#fdecea; color:var(--red-600);}

.table-footbar{
  display:flex; align-items:center; justify-content:space-between; padding:12px 16px;
  border-top:1px solid var(--line); font-size:12.5px; color:var(--ink-600); flex-wrap:wrap; gap:10px;
  background:var(--panel);
}
.table-footbar .per-page{display:flex; align-items:center; gap:7px; font-size:12.5px; color:var(--ink-600);}
.table-footbar .per-page select{min-width:0; padding:5px 8px; font-size:12px;}
.pager{display:flex; gap:5px; align-items:center; flex-wrap:wrap;}
.pager a, .pager span.disabled, .pager span.ellipsis{
  border:1px solid #d9dde3; background:#fff; border-radius:6px; padding:5px 10px; font-size:12px;
  text-decoration:none; color:var(--ink-900); min-width:30px; text-align:center;
}
.pager span.disabled{opacity:.4;}
.pager span.ellipsis{border-color:transparent; background:none; color:var(--ink-400); padding:5px 2px;}
.pager a:hover{background:#f2f4f7;}
.pager a.current, .pager span.current{
  font-weight:700; color:#fff; background:var(--navy-900); border-color:var(--navy-900);
}

@media (max-width:720px){
  .table-footbar{flex-direction:column; align-items:stretch; text-align:center;}
  .table-footbar .pager{justify-content:center;}
  .table-footbar .per-page{justify-content:center;}
}

.empty-state{padding:50px 20px; text-align:center; color:var(--ink-400);}
.empty-state svg{width:40px;height:40px; margin-bottom:10px; opacity:.5;}

/* ===== Forms (add/edit member, settings) ===== */
.form-panel{background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow-sm); padding:22px 24px; max-width:720px;}
.form-grid{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
@media (max-width:640px){.form-grid{grid-template-columns:1fr;}}
.form-field{display:flex; flex-direction:column; gap:5px; margin-bottom:14px;}
.form-field.full{grid-column:1/-1;}
.form-field label{font-size:12px; font-weight:600; color:var(--ink-600);}
.form-field .hint{font-size:11px; color:var(--ink-400); font-weight:400;}
.form-actions{display:flex; gap:10px; justify-content:flex-end; margin-top:6px;}

/* ===== Payroll form/preview ===== */
.payroll-layout{display:grid; grid-template-columns:380px 1fr; gap:20px; align-items:start;}
@media (max-width:980px){.payroll-layout{grid-template-columns:1fr;}}
.preview-card{background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:20px 22px; box-shadow:var(--shadow-sm);width: 500px;}
.field-row{display:flex; flex-direction:column; gap:5px; margin-bottom:14px;}
.field-row label{font-size:12px; font-weight:600; color:var(--ink-600);}
.field-row .hint{font-size:11px; color:var(--ink-400); font-weight:400;}
.two-col{display:grid; grid-template-columns:1fr 1fr; gap:12px;}

.preview-doc{background:#fff; border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow-sm); padding:26px 30px; font-family:'Lora', serif; max-width:1040px; margin:0 auto;}
.doc-title{text-align:center; font-weight:700; font-size:14px; letter-spacing:.3px;}
.doc-period{text-align:center; font-size:12.5px; margin-top:2px;}
.doc-brgy{text-align:center; font-size:12.5px; font-weight:600; margin-top:2px;}
.doc-ack{font-family:'Public Sans',sans-serif; font-size:11.5px; color:var(--ink-600); margin-top:14px; line-height:1.6; text-align:justify;}
.preview-table{width:100%; border-collapse:collapse; margin-top:16px; font-size:11px; font-family:'Public Sans',sans-serif;}
.preview-table th{background:#f0ede2; color:var(--ink-900); border:1px solid #d8d2bf; padding:6px 7px; font-size:9.5px; text-transform:uppercase; letter-spacing:.3px; text-align:left; font-weight:700; white-space:normal;}
.preview-table td{border:1px solid #e7e2d2; padding:5px 7px;}
.preview-table tr.subtotal td{background:#f7f4e9; font-weight:700;}
.preview-table tr.grandtotal td{background:var(--navy-900); color:#fff; font-weight:700;}

/* ===== Login ===== */
.login-wrap{
  min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:18px;
  background:radial-gradient(circle at 50% 0%, var(--navy-800) 0%, var(--navy-950) 62%);
  padding:24px;
}
.login-card{background:#fff; border-radius:14px; padding:36px 34px; width:100%; max-width:380px; box-shadow:0 20px 60px rgba(0,0,0,.4); border-top:4px solid var(--gold-500);}
.login-card .seal{margin:0 auto 14px; width:52px; height:52px; font-size:15px;}
.login-card h1{font-family:'Lora',serif; text-align:center; font-size:19px; margin:0 0 4px; color:var(--navy-950);}
.login-card p.sub{text-align:center; color:var(--ink-600); font-size:12.5px; margin:0 0 22px;}
.login-footer{color:#9fb2cf; font-size:11.5px; text-align:center;}

/* ===== Modal ===== */
.modal-overlay{
  display:none; position:fixed; inset:0; background:rgba(10,20,35,0.55);
  z-index:200; align-items:flex-start; justify-content:center; padding:5vh 20px; overflow-y:auto;
}
.modal-overlay.open{display:flex;}
.modal{
  background:var(--panel); border-radius:var(--radius); box-shadow:var(--shadow-md);
  width:100%; max-width:640px; margin:auto 0; border-top:4px solid var(--gold-500);
}
.modal-head{display:flex; align-items:flex-start; justify-content:space-between; gap:14px; padding:20px 24px 4px;}
.modal-head h3{font-family:'Lora', serif; font-size:18px; margin:0 0 4px; color:var(--navy-950); font-weight:600;}
.modal-head p{margin:0; font-size:12.5px; color:var(--ink-600);}
.modal-close{
  appearance:none; border:none; background:none; cursor:pointer; color:var(--ink-400);
  padding:4px; border-radius:6px; flex:none; margin-top:-2px;
}
.modal-close:hover{background:#f2f4f7; color:var(--navy-900);}
.modal-close svg{width:20px; height:20px; display:block;}
.modal-body{padding:16px 24px 4px; max-height:70vh; overflow-y:auto;}
.modal-foot{display:flex; gap:10px; justify-content:flex-end; padding:16px 24px 22px;}
.modal .form-grid{margin-bottom:0;}

::-webkit-scrollbar{width:9px; height:9px;}
::-webkit-scrollbar-thumb{background:#cfd3da; border-radius:6px;}

@media print{
  .no-print{display:none !important;}
}
