:root {
  --pm-green: #064E3B;
  --pm-green-hover: #065F46;
  --pm-green-light: #10B981;
  --pm-green-soft: #ECFDF5;
  --pm-green-border: #A7F3D0;
  --pm-white: #FFFFFF;
  --pm-bg: #F1F5F9;
  --pm-surface: #FFFFFF;
  --pm-text: #0F172A;
  --pm-text-muted: #64748B;
  --pm-border: #E2E8F0;
  --pm-sidebar-width: 260px;
  --pm-navbar-h: 60px;
  --pm-radius: 12px;
  --pm-shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --pm-shadow-sm: 0 1px 2px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

body.pm-body {
  background: var(--pm-bg);
  color: var(--pm-text);
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.9375rem;
}

/* ── NAVBAR ── */
.pm-navbar {
  background: var(--pm-green) !important;
  box-shadow: 0 2px 16px rgba(6,78,59,.22);
  height: var(--pm-navbar-h);
  padding: 0 1.25rem;
}
.pm-navbar .navbar-brand {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: #fff !important;
}
.pm-navbar .navbar-brand small {
  font-size: .65rem;
  font-weight: 400;
  opacity: .65;
  display: block;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.pm-sidebar-toggle {
  border-color: rgba(255,255,255,.35);
  color: #fff;
  padding: .35rem .6rem;
  font-size: 1.05rem;
  line-height: 1;
}
.pm-sidebar-toggle:hover { background: rgba(255,255,255,.12); }

.pm-user-pill {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: rgba(255,255,255,.9);
  font-size: .82rem;
}
.pm-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.pm-role-badge {
  font-size: .65rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  color: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.25);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.pm-logout-btn {
  padding: .3rem .75rem;
  font-size: .8rem;
  border-color: rgba(255,255,255,.4);
  color: #fff !important;
  border-radius: 8px;
}
.pm-logout-btn:hover { background: rgba(255,255,255,.15) !important; }

/* ── LAYOUT ── */
.pm-layout {
  display: flex;
  min-height: calc(100vh - var(--pm-navbar-h));
  position: relative;
}

/* ── SIDEBAR ── */
.pm-sidebar {
  width: var(--pm-sidebar-width);
  background: var(--pm-green);
  color: var(--pm-white);
  min-height: calc(100vh - var(--pm-navbar-h));
  position: sticky;
  top: var(--pm-navbar-h);
  transition: width .25s ease, transform .25s ease;
  z-index: 1030;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pm-sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pm-sidebar-header .pm-menu-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  opacity: .55;
}
.pm-menu {
  padding: .75rem .625rem;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.pm-menu-section {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.4);
  padding: .75rem .5rem .25rem;
  white-space: nowrap;
}
.pm-menu a {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  padding: .65rem .875rem;
  border-radius: 9px;
  margin-bottom: .15rem;
  font-weight: 500;
  font-size: .875rem;
  white-space: nowrap;
  transition: background .15s, color .15s;
  position: relative;
}
.pm-menu a .pm-nav-icon {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: .85;
}
.pm-menu a .pm-nav-text { flex: 1; }
.pm-menu a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.pm-menu a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  font-weight: 600;
}
.pm-menu a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 3px;
  background: #34D399;
  border-radius: 0 3px 3px 0;
}
.pm-sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .75rem;
  color: rgba(255,255,255,.35);
  white-space: nowrap;
}

/* ── COLLAPSED SIDEBAR ── */
body.sidebar-collapsed .pm-sidebar { width: 0; overflow: hidden; }
body.sidebar-collapsed .pm-main { width: 100%; }

/* ── MAIN CONTENT ── */
.pm-main {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 2rem;
  transition: margin .25s ease;
  width: 100%;
}
.pm-main-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  min-height: calc(100vh - var(--pm-navbar-h));
  background: linear-gradient(135deg, var(--pm-green) 0%, var(--pm-green-hover) 50%, #022C22 100%);
}

/* ── PAGE HEADER ── */
.pm-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.pm-page-header h1, .pm-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--pm-text);
  margin: 0;
  line-height: 1.2;
}
.pm-page-header .pm-page-subtitle {
  font-size: .8rem;
  color: var(--pm-text-muted);
  margin-top: .2rem;
}
.pm-page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── CARDS ── */
.card {
  border: 1px solid var(--pm-border);
  border-radius: var(--pm-radius);
  box-shadow: var(--pm-shadow-sm);
  background: var(--pm-surface);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--pm-border);
  font-weight: 600;
  color: var(--pm-text);
  padding: .875rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
}
.card-header .bi { color: var(--pm-green); font-size: 1rem; }
.card-body { padding: 1.25rem; }

/* ── STAT CARDS ── */
.pm-stat-card {
  border-radius: var(--pm-radius);
  padding: 1.25rem 1.5rem;
  background: var(--pm-surface);
  border: 1px solid var(--pm-border);
  box-shadow: var(--pm-shadow-sm);
  position: relative;
  overflow: hidden;
}
.pm-stat-card .pm-stat-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--pm-text-muted);
  margin-bottom: .4rem;
}
.pm-stat-card .pm-stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--pm-text);
  line-height: 1;
  margin-bottom: .25rem;
}
.pm-stat-card .pm-stat-badge {
  font-size: .78rem;
  color: var(--pm-text-muted);
}
.pm-stat-icon {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}
.pm-stat-icon.green { background: var(--pm-green-soft); color: var(--pm-green); }
.pm-stat-icon.blue  { background: #EFF6FF; color: #2563EB; }
.pm-stat-icon.amber { background: #FFFBEB; color: #D97706; }
.pm-stat-icon.rose  { background: #FFF1F2; color: #E11D48; }
.pm-stat-icon.purple { background: #F5F3FF; color: #7C3AED; }

/* ── TABLES ── */
.table-card {
  border-radius: var(--pm-radius);
  overflow: hidden;
  border: 1px solid var(--pm-border);
  box-shadow: var(--pm-shadow-sm);
}
.table {
  margin-bottom: 0;
  font-size: .875rem;
  background: var(--pm-surface);
}
.table thead th {
  background: var(--pm-green-soft);
  color: var(--pm-green);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-bottom: 1px solid var(--pm-green-border);
  padding: .75rem 1rem;
  white-space: nowrap;
}
.table tbody td {
  padding: .75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--pm-border);
  color: var(--pm-text);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #F8FAFC; }
.table-responsive { border-radius: var(--pm-radius); }

/* ── BADGES ── */
.badge {
  font-size: .7rem;
  font-weight: 600;
  padding: .3em .65em;
  border-radius: 6px;
  letter-spacing: .02em;
}
.badge-status-active, .bg-success { background-color: #DCFCE7 !important; color: #15803D !important; }
.badge-status-inactive, .bg-secondary { background-color: #F1F5F9 !important; color: #64748B !important; }
.badge-status-pending { background-color: #FEF9C3 !important; color: #A16207 !important; }
.badge-status-approved { background-color: #DCFCE7 !important; color: #15803D !important; }
.badge-status-rejected { background-color: #FEE2E2 !important; color: #DC2626 !important; }
.badge-status-locked { background-color: #EDE9FE !important; color: #6D28D9 !important; }
.badge-status-computed { background-color: #DBEAFE !important; color: #1D4ED8 !important; }
.badge-status-draft { background-color: #F1F5F9 !important; color: #64748B !important; }
.bg-warning { background-color: #FEF9C3 !important; color: #A16207 !important; }

/* ── BUTTONS ── */
.btn {
  font-weight: 500;
  font-size: .85rem;
  border-radius: 8px;
  padding: .45rem .95rem;
  transition: all .15s;
}
.btn-primary, .btn-success {
  background: var(--pm-green);
  border-color: var(--pm-green);
  color: #fff;
}
.btn-primary:hover, .btn-success:hover,
.btn-primary:focus, .btn-success:focus {
  background: var(--pm-green-hover);
  border-color: var(--pm-green-hover);
  color: #fff;
}
.btn-outline-primary {
  color: var(--pm-green);
  border-color: var(--pm-green);
}
.btn-outline-primary:hover {
  background: var(--pm-green);
  border-color: var(--pm-green);
  color: #fff;
}
.btn-sm {
  font-size: .78rem;
  padding: .3rem .7rem;
  border-radius: 6px;
}
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
}

/* ── ALERTS ── */
.alert {
  border-radius: 10px;
  border: none;
  font-size: .875rem;
  padding: .875rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: .625rem;
}
.alert-success {
  background: var(--pm-green-soft);
  color: #065F46;
}
.alert-danger {
  background: #FEF2F2;
  color: #991B1B;
}
.alert-warning {
  background: #FFFBEB;
  color: #92400E;
}
.alert-info {
  background: #EFF6FF;
  color: #1E40AF;
}

/* ── FORMS ── */
.form-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--pm-text);
  margin-bottom: .35rem;
}
.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid var(--pm-border);
  font-size: .875rem;
  padding: .5rem .875rem;
  color: var(--pm-text);
  background: #FAFAFA;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--pm-green);
  box-shadow: 0 0 0 3px rgba(6,78,59,.1);
  background: #fff;
}
.form-control::placeholder { color: #94A3B8; }
.input-group-text {
  background: var(--pm-green-soft);
  border-color: var(--pm-border);
  color: var(--pm-green);
  font-size: .875rem;
}

/* ── DIVIDERS ── */
.pm-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--pm-text-muted);
  margin-bottom: .875rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.pm-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--pm-border);
}

/* ── LOGIN ── */
.login-card {
  width: 100%;
  max-width: 440px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  border: none;
}
.login-brand {
  background: var(--pm-green);
  color: var(--pm-white);
  padding: 2rem 1.5rem 1.75rem;
  text-align: center;
}
.login-brand .bi {
  font-size: 2.25rem;
  opacity: .9;
  display: block;
  margin-bottom: .6rem;
}
.login-brand h4 { font-weight: 800; margin-bottom: .15rem; letter-spacing: -.02em; }
.login-brand p  { margin: 0; opacity: .65; font-size: .82rem; }
.login-card .card-body { padding: 1.75rem; background: #fff; }
.login-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1rem 0;
  color: var(--pm-text-muted);
  font-size: .78rem;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--pm-border);
}

/* ── ACTION ROW ── */
.pm-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .875rem 1.25rem;
  background: var(--pm-surface);
  border: 1px solid var(--pm-border);
  border-radius: var(--pm-radius) var(--pm-radius) 0 0;
  border-bottom: none;
}

/* ── EMPTY STATE ── */
.pm-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--pm-text-muted);
}
.pm-empty .bi { font-size: 2.5rem; opacity: .3; display: block; margin-bottom: .75rem; }
.pm-empty p { font-size: .875rem; margin: 0; }

/* ── PERIOD ITEM ── */
.pm-period-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--pm-border);
}
.pm-period-item:last-child { border-bottom: none; }
.pm-period-meta { flex: 1; min-width: 0; }
.pm-period-dates { font-weight: 600; font-size: .875rem; color: var(--pm-text); }
.pm-period-actions { display: flex; gap: .375rem; flex-wrap: wrap; }

/* ── RESPONSIVE ── */
@media (max-width: 991.98px) {
  .pm-layout { display: block; }
  .pm-sidebar {
    position: fixed;
    top: var(--pm-navbar-h);
    left: 0;
    bottom: 0;
    min-height: calc(100vh - var(--pm-navbar-h));
    transform: translateX(-100%);
    width: min(86vw, var(--pm-sidebar-width));
    overflow-y: auto;
  }
  body.sidebar-open .pm-sidebar { transform: translateX(0); }
  body.sidebar-collapsed .pm-sidebar { width: min(86vw, var(--pm-sidebar-width)); transform: translateX(-100%); }
  .pm-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--pm-navbar-h) 0 0 0;
    background: rgba(15,23,42,.45);
    z-index: 1029;
  }
  body.sidebar-open .pm-sidebar-backdrop { display: block; }
  .pm-main { padding: 1rem; width: 100%; }
  .card { border-radius: .875rem; }
  .row > [class*="col"] { margin-bottom: .5rem; }
}
@media (max-width: 575.98px) {
  .pm-main { padding: .875rem; }
  .pm-page-header h1, .pm-page-title { font-size: 1.25rem; }
  .pm-stat-card .pm-stat-value { font-size: 1.6rem; }
  .btn { white-space: normal; }
  .pm-period-item { flex-direction: column; align-items: flex-start; }
  form.row.g-2 > [class*="col"] { flex: 0 0 100%; max-width: 100%; }
}

/* ── PRINT ── */
@media print {
  nav, .pm-sidebar, .pm-sidebar-backdrop, .btn, .no-print { display: none !important; }
  .pm-layout { display: block !important; min-height: auto !important; }
  .pm-main { padding: 0 !important; width: 100% !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  body { background: #fff !important; color: #000 !important; }
}

/* ── LINKS ── */
a { color: var(--pm-green); }
a:hover { color: var(--pm-green-hover); }

/* ── SCROLLBAR (sidebar) ── */
.pm-menu::-webkit-scrollbar { width: 4px; }
.pm-menu::-webkit-scrollbar-track { background: transparent; }
.pm-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }
