/* ============================================================
   MID Internal System — shared design tokens & app shell
   Same brand colors/type as the public site, restructured as
   an application (sidebar + topbar) rather than a marketing page.
   ============================================================ */

:root{
  --ink:#182420;
  --ink-soft:#3d4c47;
  --bg:#f6f3ea;
  --bg-alt:#eee6d4;
  --bg-deep:#0f2b24;
  --primary:#0f5c4c;
  --primary-dark:#0a3f34;
  --gold:#c08829;
  --gold-soft:#e9c876;
  --clay:#b5542a;
  --red:#b3261e;
  --red-soft:#fbe9e7;
  --amber:#a6740f;
  --amber-soft:#fbf1dc;
  --green:#0f5c4c;
  --green-soft:#e4efe9;
  --line:rgba(24,36,32,0.12);
  --line-soft:rgba(24,36,32,0.07);
  --radius:5px;
  --shadow-sm:0 1px 2px rgba(15,43,36,0.06);
  --shadow-md:0 8px 24px rgba(15,43,36,0.09);
  --shadow-lg:0 24px 56px rgba(15,43,36,0.16);
  --ease:cubic-bezier(.22,.61,.36,1);
  --sidebar-w:254px;
  --topbar-h:68px;
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:'Montserrat', sans-serif;
  font-size:14.5px;
  line-height:1.6;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4{font-family:'Montserrat', sans-serif; font-weight:600; margin:0; color:var(--ink); letter-spacing:-0.01em;}
p{margin:0;}
a{color:inherit; text-decoration:none;}
ul{margin:0; padding:0; list-style:none;}
button{font-family:inherit; cursor:pointer;}
table{border-collapse:collapse; width:100%;}

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible{
  outline:2px solid var(--gold); outline-offset:2px;
}

/* ============ APP SHELL ============ */
.app-shell{display:flex; min-height:100vh;}

.sidebar{
  width:var(--sidebar-w); flex-shrink:0;
  background:var(--bg-deep); color:#fff;
  display:flex; flex-direction:column;
  position:sticky; top:0; height:100vh; overflow-y:auto;
  box-shadow:var(--shadow-lg);
}
.sidebar-brand{
  display:flex; align-items:center; gap:12px;
  padding:24px 22px 20px;
  border-bottom:1px solid rgba(255,255,255,0.1);
}
.sidebar-brand .mark{
  width:35px; height:35px; position:relative; flex-shrink:0;
  background:#fff;
  padding:3px;
  border-radius:6px;
  box-sizing:border-box;
  object-fit:contain;
}
.sidebar-brand .mark span{position:absolute; inset:0; border:2px solid var(--gold); transform:rotate(45deg);}
.sidebar-brand strong{
  display:block; font-family:'Montserrat', sans-serif; font-size:14.5px; font-weight:600;
}
.sidebar-brand small{
  display:block; font-size:10.5px; color:rgba(255,255,255,0.5);
  text-transform:uppercase; letter-spacing:0.07em; margin-top:3px;
}

.sidebar-nav{padding:16px 14px; flex-grow:1;}
.nav-group{margin-bottom:4px;}
.nav-group-label{
  font-family:'Montserrat', sans-serif; font-size:10.5px; font-weight:700;
  letter-spacing:0.1em; text-transform:uppercase;
  color:rgba(255,255,255,0.38);
  padding:18px 12px 8px;
}
.nav-link{
  display:flex; align-items:center; gap:12px;
  padding:11px 13px; margin-bottom:3px;
  border-radius:6px;
  font-size:14px; font-weight:500;
  color:rgba(255,255,255,0.72);
  transition:all .16s var(--ease);
}
.nav-link svg{width:17px; height:17px; flex-shrink:0; opacity:0.85;}
.nav-link:hover{background:rgba(255,255,255,0.07); color:#fff;}
.nav-link.active{background:var(--primary); color:#fff; box-shadow:var(--shadow-sm);}
.nav-link.active svg{opacity:1;}
.nav-badge{
  margin-left:auto; flex-shrink:0;
  min-width:18px; height:18px; padding:0 5px; border-radius:20px;
  background:var(--clay); color:#fff;
  font-size:10.5px; font-weight:700;
  display:flex; align-items:center; justify-content:center;
}

.sidebar-foot{
  padding:16px 22px 22px;
  border-top:1px solid rgba(255,255,255,0.1);
  font-size:12px; color:rgba(255,255,255,0.42); line-height:1.6;
}

/* ============ MAIN COLUMN ============ */
.main-col{flex:1; min-width:0; display:flex; flex-direction:column;}

.topbar{
  height:var(--topbar-h); flex-shrink:0;
  background:#fff; border-bottom:1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between;
  padding:0 28px;
  position:sticky; top:0; z-index:30;
}
.topbar-title{font-family:'Montserrat', sans-serif; font-size:18px; font-weight:600;}
.topbar-title small{
  display:block; font-family:'Montserrat', sans-serif; font-weight:400; font-size:12.5px; color:var(--ink-soft); margin-top:2px;
}
.topbar-right{display:flex; align-items:center; gap:20px;}

.topbar-clock{
  display:flex; align-items:center; gap:7px;
  background:var(--bg); border:1px solid var(--line); border-radius:20px;
  padding:7px 14px;
  font-family:'Montserrat', sans-serif; font-size:12.5px; font-weight:600;
  color:var(--ink-soft); white-space:nowrap;
}
.topbar-clock-icon{width:14px; height:14px; opacity:0.7; flex-shrink:0;}
.topbar-clock-time{color:var(--ink); font-weight:700; font-variant-numeric:tabular-nums; letter-spacing:0.01em;}
.topbar-clock-sep{opacity:0.5;}

.icon-btn{
  width:40px; height:40px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background:var(--bg); border:1px solid var(--line); color:var(--ink-soft);
  position:relative; transition:all .16s var(--ease);
}
.icon-btn:hover{border-color:var(--primary); color:var(--primary); box-shadow:var(--shadow-sm);}
.icon-btn svg{width:17px; height:17px;}
.badge-dot{
  position:absolute; top:-3px; right:-3px;
  width:17px; height:17px; border-radius:50%;
  background:var(--clay); color:#fff;
  font-size:9.5px; font-weight:700;
  display:flex; align-items:center; justify-content:center;
  border:2px solid #fff;
}

.user-chip{display:flex; align-items:center; gap:10px; position:relative;}
.user-avatar{
  width:38px; height:38px; border-radius:50%;
  background:var(--gold); color:var(--bg-deep);
  display:flex; align-items:center; justify-content:center;
  font-family:'Montserrat', sans-serif; font-weight:700; font-size:12.5px;
}
.user-meta{display:flex; flex-direction:column; line-height:1.3;}
.user-meta strong{font-size:13.5px; font-weight:600;}
.user-meta span{font-size:11.5px; color:var(--ink-soft); text-transform:capitalize;}

.dropdown-panel{
  position:absolute; top:calc(100% + 12px); right:0;
  background:#fff; border:1px solid var(--line); border-radius:8px;
  box-shadow:var(--shadow-lg);
  width:290px; z-index:50; overflow:hidden;
}
.dropdown-panel[hidden]{display:none;}
.dropdown-head{padding:15px 17px; border-bottom:1px solid var(--line); font-size:13px; font-weight:700; background:var(--bg-alt);}
.dropdown-list{max-height:340px; overflow-y:auto;}
.dropdown-item{padding:13px 17px; border-bottom:1px solid var(--line-soft); font-size:13px;}
.dropdown-item:last-child{border-bottom:none;}
.dropdown-item .dt{font-size:11px; color:var(--ink-soft); margin-top:4px;}
.dropdown-item.unread{background:var(--green-soft);}
.dropdown-empty{padding:26px 17px; text-align:center; font-size:13px; color:var(--ink-soft);}
.dropdown-foot{padding:11px 17px; border-top:1px solid var(--line);}
.dropdown-foot button{
  width:100%; background:none; border:1px solid var(--line); padding:9px; font-size:12.5px;
  font-weight:600; color:var(--ink-soft); border-radius:6px;
}
.dropdown-foot button:hover{border-color:var(--primary); color:var(--primary);}

.menu-list{padding:8px 0;}
.menu-list a, .menu-list button{
  display:block; width:100%; text-align:left;
  padding:12px 17px; font-size:13.5px; color:var(--ink);
  background:none; border:none;
}
.menu-list a:hover, .menu-list button:hover{background:var(--bg);}
.menu-list button.danger{color:var(--red);}

.page-body{padding:32px 34px 64px;}

/* ============ COMMON UI ============ */
.page-head{display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:30px; flex-wrap:wrap;}
.page-head h1{font-size:22px;}
.page-head p{color:var(--ink-soft); font-size:14.5px; margin-top:7px; max-width:60ch; line-height:1.65;}

.btn{
  display:inline-flex; align-items:center; gap:8px;
  padding:11px 20px; font-size:13.5px; font-weight:600;
  border-radius:6px; border:1px solid transparent;
  transition:all .16s var(--ease);
}
.btn svg{width:15px; height:15px;}
.btn-primary{background:var(--primary); color:#fff; box-shadow:var(--shadow-sm);}
.btn-primary:hover{background:var(--primary-dark); box-shadow:var(--shadow-md); transform:translateY(-1px);}
.btn-ghost{background:none; border-color:var(--ink); color:var(--ink);}
.btn-ghost:hover{background:var(--ink); color:#fff;}
.btn-outline{background:#fff; border-color:var(--line); color:var(--ink-soft);}
.btn-outline:hover{border-color:var(--primary); color:var(--primary); box-shadow:var(--shadow-sm);}
.btn-danger{background:none; border-color:var(--red); color:var(--red);}
.btn-danger:hover{background:var(--red); color:#fff;}
.btn-sm{padding:8px 14px; font-size:12.5px; border-radius:5px;}
.btn[disabled]{opacity:0.45; cursor:not-allowed;}

.card{background:#fff; border:1px solid var(--line); border-radius:8px; box-shadow:var(--shadow-sm);}
.card-pad{padding:24px 26px;}

/* stat cards */
.stat-grid{display:grid; grid-template-columns:repeat(auto-fit, minmax(210px, 1fr)); gap:18px; margin-bottom:30px;}
.stat-card{background:#fff; border:1px solid var(--line); border-top:3px solid var(--gold); border-radius:8px; padding:22px 24px; box-shadow:var(--shadow-sm); transition:box-shadow .18s var(--ease);}
.stat-card:hover{box-shadow:var(--shadow-md);}
.stat-card .stat-label{font-family:'Montserrat', sans-serif; font-size:11.5px; font-weight:700; letter-spacing:0.06em; text-transform:uppercase; color:var(--ink-soft);}
.stat-card .stat-value{font-family:'Montserrat', sans-serif; font-size:23px; font-weight:600; margin-top:9px;}
.stat-card .stat-sub{font-size:12.5px; color:var(--ink-soft); margin-top:5px;}
.stat-card.accent-red{border-top-color:var(--red);}
.stat-card.accent-green{border-top-color:var(--primary);}

/* badges */
.badge{
  display:inline-flex; align-items:center; gap:5px;
  font-size:11.5px; font-weight:700; letter-spacing:0.02em;
  padding:5px 11px; border-radius:20px;
}
.badge-green{background:var(--green-soft); color:var(--green);}
.badge-amber{background:var(--amber-soft); color:var(--amber);}
.badge-red{background:var(--red-soft); color:var(--red);}
.badge-gray{background:var(--bg-alt); color:var(--ink-soft);}

/* tables */
.table-wrap{overflow-x:auto; border:1px solid var(--line); border-radius:8px; background:#fff; box-shadow:var(--shadow-sm);}
table.data-table{min-width:100%;}
.data-table th{
  text-align:left; font-family:'Montserrat', sans-serif; font-size:11.5px; font-weight:700;
  letter-spacing:0.05em; text-transform:uppercase; color:var(--ink-soft);
  padding:13px 18px; border-bottom:1px solid var(--line); background:var(--bg-alt);
  white-space:nowrap;
}
.data-table td{padding:13px 18px; border-bottom:1px solid var(--line-soft); font-size:13.8px; vertical-align:middle;}
.data-table tr:last-child td{border-bottom:none;}
.data-table tr:hover td{background:var(--bg);}
.num{font-family:'Montserrat', sans-serif; font-variant-numeric:tabular-nums;}
.row-actions{display:flex; gap:6px;}

/* section tabs (Programs vs M&E, report periods, etc.) */
.section-tabs{display:inline-flex; gap:4px; border:1px solid var(--line); padding:4px; background:#fff; margin-bottom:24px; border-radius:8px; box-shadow:var(--shadow-sm);}
.section-tabs button{
  background:none; border:none;
  font-family:'Montserrat', sans-serif; font-size:13px; font-weight:600;
  color:var(--ink-soft); padding:10px 22px; border-radius:5px;
}
.section-tabs button.active{background:var(--primary); color:#fff;}
.section-tabs button:not(.active):hover{color:var(--primary);}

/* forms */
.form-grid{display:grid; grid-template-columns:1fr 1fr; gap:18px;}
.form-grid.single{grid-template-columns:1fr;}
@media (max-width:720px){ .form-grid{grid-template-columns:1fr;} }
.field{margin-bottom:18px;}
.field label{display:block; font-family:'Montserrat', sans-serif; font-size:12px; font-weight:700; color:var(--ink); margin-bottom:7px;}
.field .req{color:var(--clay);}
.field input, .field select, .field textarea{
  width:100%; font-family:'Montserrat', sans-serif; font-size:14.5px; color:var(--ink);
  background:var(--bg); border:1px solid var(--line); padding:11px 13px; border-radius:6px;
  transition:border-color .16s, background .16s;
}
.field input:focus, .field select:focus, .field textarea:focus{outline:none; border-color:var(--primary); background:#fff; box-shadow:0 0 0 3px rgba(15,92,76,0.1);}
.field textarea{resize:vertical; min-height:84px; font-family:inherit;}
.field-hint{font-size:11.5px; color:var(--ink-soft); margin-top:6px; line-height:1.5;}

/* modal */
.modal-overlay{
  position:fixed; inset:0; background:rgba(15,43,36,0.55);
  display:flex; align-items:flex-start; justify-content:center;
  padding:40px 20px; overflow-y:auto; z-index:100;
  backdrop-filter:blur(2px);
}
.modal-overlay[hidden]{display:none;}
.modal{background:#fff; width:100%; max-width:640px; border-radius:10px; overflow:hidden; box-shadow:var(--shadow-lg);}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:19px 24px; border-bottom:1px solid var(--line); background:var(--bg-alt);
}
.modal-head h3{font-size:16px;}
.modal-close{background:none; border:none; width:32px; height:32px; display:flex; align-items:center; justify-content:center; color:var(--ink-soft); border-radius:50%;}
.modal-close:hover{color:var(--ink); background:rgba(0,0,0,0.05);}
.modal-body{padding:24px; max-height:70vh; overflow-y:auto;}
.modal-foot{padding:16px 24px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:10px; background:var(--bg-alt);}

/* empty state */
.empty-state{padding:48px 24px; text-align:center; color:var(--ink-soft); font-size:14px; background:#fff; border:1px dashed var(--line); border-radius:8px;}

/* toast */
.toast{
  position:fixed; bottom:26px; right:26px; z-index:200;
  background:var(--ink); color:#fff; padding:14px 22px;
  border-radius:8px; font-size:13.5px; font-weight:500;
  box-shadow:var(--shadow-lg);
  display:flex; align-items:center; gap:10px;
  transform:translateY(12px); opacity:0; transition:all .25s var(--ease);
  pointer-events:none;
}
.toast.show{transform:translateY(0); opacity:1;}
.toast.error{background:var(--red);}

/* charts container */
.chart-card{background:#fff; border:1px solid var(--line); border-radius:8px; padding:22px 24px; box-shadow:var(--shadow-sm);}
.chart-card h3{font-size:14.5px; margin-bottom:16px;}
.bar-row{display:flex; align-items:center; gap:12px; margin-bottom:13px;}
.bar-label{width:170px; flex-shrink:0; font-size:12.5px; color:var(--ink-soft); overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.bar-track{flex:1; height:13px; background:var(--bg-alt); border-radius:8px; overflow:hidden; position:relative;}
.bar-fill{height:100%; background:var(--primary); border-radius:8px; transition:width .4s var(--ease);}
.bar-fill.over{background:var(--clay);}
.bar-value{width:64px; flex-shrink:0; text-align:right; font-size:12px; font-weight:700; font-family:'Montserrat', sans-serif;}

/* responsive */
.menu-toggle-mobile{display:none;}
@media (max-width:960px){
  .sidebar{position:fixed; left:0; top:0; z-index:60; transform:translateX(-100%); transition:transform .22s var(--ease);}
  .sidebar.open{transform:translateX(0);}
  .menu-toggle-mobile{
    display:flex; align-items:center; justify-content:center;
    width:38px; height:38px; border-radius:50%; background:var(--bg); border:1px solid var(--line);
  }
  .sidebar-scrim{position:fixed; inset:0; background:rgba(0,0,0,0.4); z-index:55; display:none;}
  .sidebar-scrim.show{display:block;}
  .page-body{padding:20px;}
  .form-grid{grid-template-columns:1fr;}
}
@media (max-width:720px){
  .topbar-clock-date, .topbar-clock-sep{display:none;}
  .topbar-clock{padding:7px 11px;}
}
