@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --sidebar: #0f172a;
  --sidebar-2: #111827;
  --brand: #2563eb;
  --brand-2: #06b6d4;
  --brand-3: #7c3aed;
  --bg: #f5f7fb;
  --card: rgba(255, 255, 255, .92);
  --card-solid: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, .10);
  --shadow: 0 22px 60px rgba(15, 23, 42, .08);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, .06);
  --radius: 22px;
}

[data-bs-theme="dark"] {
  --bg: #0b1120;
  --card: rgba(17, 24, 39, .88);
  --card-solid: #111827;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --line: rgba(255, 255, 255, .10);
  --shadow: 0 22px 60px rgba(0, 0, 0, .25);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }

body {
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, .12), transparent 34rem),
    radial-gradient(circle at top right, rgba(6, 182, 212, .12), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  min-height: 100vh;
}

a { text-decoration: none; }

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

.erp-sidebar {
  width: 286px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .98), rgba(17, 24, 39, .98)),
    radial-gradient(circle at top, rgba(37, 99, 235, .35), transparent 20rem);
  border-right: 1px solid rgba(255, 255, 255, .08);
  padding: 24px 18px;
  position: fixed;
  inset: 0 auto 0 0;
  overflow-y: auto;
  z-index: 20;
}

/* Sidebar header (sticky, with close icon + logo) */
.sidebar-header {
  align-items: center;
  color: #fff;
  display: flex;
  gap: 12px;
  padding: 16px 8px 20px;
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 2;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  padding: 4px;
  flex-shrink: 0;
}

.sidebar-brand-text strong { display: block; font-size: 1rem; letter-spacing: -.01em; }
.sidebar-brand-text span { color: #94a3b8; display: block; font-size: .78rem; }

.sidebar-icon-btn {
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 1.3rem;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
  transition: background .18s ease, color .18s ease;
}
.sidebar-icon-btn:hover { background: rgba(255, 255, 255, .10); color: #fff; }

.sidebar-close { display: none; } /* hidden on desktop, shown on mobile */

.erp-sidebar .nav { margin-top: 10px; }

.erp-sidebar .nav-link {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 16px;
  color: #cbd5e1;
  display: flex;
  font-size: 15px;
  font-weight: 600;
  gap: 12px;
  margin-bottom: 6px;
  min-height: 44px;
  padding: 12px 14px;
  transition: all .18s ease;
}

.erp-sidebar .nav-link i { color: #93c5fd; font-size: 15px; }
.erp-sidebar .nav-link.active,
.erp-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, .10);
  border-color: rgba(255, 255, 255, .10);
  box-shadow: inset 3px 0 0 var(--brand-2);
  color: #fff;
  transform: translateX(2px);
}

/* Parent/child collapsible navigation */
.erp-sidebar .nav-group { margin-bottom: 6px; }

.erp-sidebar .nav-toggle {
  width: 100%;
  background: none;
  cursor: pointer;
  text-align: left;
}

.erp-sidebar .nav-toggle .nav-caret {
  color: #93c5fd;
  font-size: .85rem;
  transition: transform .2s ease;
}

.erp-sidebar .nav-group.open .nav-toggle .nav-caret { transform: rotate(180deg); }

.erp-sidebar .nav-children {
  max-height: 0;
  overflow: hidden;
  padding-left: 14px;
  margin-top: 0;
  transition: max-height .28s ease, margin-top .28s ease;
}

.erp-sidebar .nav-group.open .nav-children {
  max-height: 600px;
  margin-top: 2px;
}

.erp-sidebar .nav-child {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
  padding: 9px 12px;
}

.erp-sidebar .nav-child i { font-size: 15px; }

/* Hamburger toggle (inside topbar, mobile only) */
.sidebar-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 1.4rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-brand {
  display: none;
  align-items: center;
  gap: 8px;
}
.topbar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
}
.topbar-app-name {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -.02em;
  white-space: nowrap;
}

/* Dark overlay backdrop (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 1045;
  opacity: 0;
  transition: opacity .25s ease;
}

.sidebar-overlay.show { display: block; opacity: 1; }

.erp-main { flex: 1; margin-left: 286px; min-width: 0; }

.erp-topbar {
  align-items: center;
  backdrop-filter: blur(18px);
  background: rgba(255, 255, 255, .76);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 90px;
  justify-content: space-between;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 16px;
}

[data-bs-theme="dark"] .erp-topbar { background: rgba(17, 24, 39, .76); }
.erp-topbar h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; margin: 0; }

.topbar-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar-center { flex: 1; min-width: 0; overflow: hidden; }
.topbar-center h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { flex-shrink: 0; }
.erp-content { padding: 30px; }

.panel,
.stat-card,
.hero-panel,
.active-session-card {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.panel {
  border-radius: var(--radius);
  padding: 24px;
}

.hero-panel {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .96), rgba(255, 255, 255, .82)),
    linear-gradient(135deg, rgba(37, 99, 235, .14), rgba(6, 182, 212, .12));
  border-radius: 28px;
  display: flex;
  gap: 22px;
  justify-content: space-between;
  overflow: hidden;
  padding: 28px;
  position: relative;
}

[data-bs-theme="dark"] .hero-panel {
  background:
    linear-gradient(135deg, rgba(17, 24, 39, .95), rgba(15, 23, 42, .82)),
    linear-gradient(135deg, rgba(37, 99, 235, .20), rgba(6, 182, 212, .14));
}

.hero-panel::after {
  background: linear-gradient(135deg, rgba(37, 99, 235, .24), rgba(6, 182, 212, .2));
  border-radius: 999px;
  content: "";
  height: 170px;
  position: absolute;
  right: -60px;
  top: -70px;
  width: 170px;
}

.hero-panel h2 { font-size: 1.65rem; font-weight: 800; letter-spacing: -.04em; }

.eyebrow {
  color: var(--brand);
  display: inline-block;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.active-session-card {
  background: linear-gradient(135deg, rgba(37, 99, 235, .96), rgba(6, 182, 212, .92));
  border: 0;
  border-radius: 22px;
  box-shadow: 0 18px 40px rgba(37, 99, 235, .22);
  color: #fff;
  min-width: 250px;
  padding: 18px 20px;
  position: relative;
  z-index: 1;
}

.active-session-card span,
.active-session-card small { color: rgba(255, 255, 255, .78); display: block; }
.active-session-card strong { display: block; font-size: 1.45rem; font-weight: 800; line-height: 1.2; margin: 4px 0; }

.section-heading {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.stat-card {
  align-items: center;
  border-radius: 22px;
  display: flex;
  justify-content: space-between;
  min-height: 132px;
  overflow: hidden;
  padding: 24px;
  position: relative;
}

.stat-card::after {
  background: linear-gradient(135deg, rgba(37, 99, 235, .12), rgba(6, 182, 212, .10));
  border-radius: 999px;
  content: "";
  height: 110px;
  position: absolute;
  right: -34px;
  top: -34px;
  width: 110px;
}

.stat-card span { color: var(--muted); display: block; font-weight: 700; }
.stat-card strong { display: block; font-size: 2.15rem; font-weight: 800; letter-spacing: -.05em; }
.stat-card i { color: var(--brand); font-size: 2.6rem; position: relative; z-index: 1; }

.chart-panel canvas { min-height: 260px; }

.user-chip {
  align-items: center;
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  font-weight: 700;
  gap: 8px;
  padding: 9px 13px;
}

.btn { border-radius: 12px; font-weight: 700; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: 0; box-shadow: 0 10px 24px rgba(37, 99, 235, .18); }
.btn-primary:hover { filter: brightness(.98); transform: translateY(-1px); }
.btn-outline-primary { border-color: rgba(37, 99, 235, .32); color: var(--brand); }
.btn-light { background: var(--card-solid); }

.form-label { color: var(--text); font-size: .86rem; font-weight: 800; }
.form-control,
.form-select,
.vscomp-toggle-button {
  background-color: var(--card-solid) !important;
  border: 1px solid var(--line) !important;
  border-radius: 14px !important;
  color: var(--text) !important;
  min-height: 45px;
}

.form-control:focus,
.form-select:focus,
.vscomp-toggle-button:focus {
  border-color: rgba(37, 99, 235, .55) !important;
  box-shadow: 0 0 0 .25rem rgba(37, 99, 235, .12) !important;
}

.form-text,
.text-muted { color: var(--muted) !important; }

.readonly-control {
  align-items: center;
  background: linear-gradient(135deg, rgba(37, 99, 235, .08), rgba(6, 182, 212, .08));
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  display: flex;
  font-weight: 800;
  gap: 10px;
  min-height: 45px;
  padding: 10px 13px;
}

.readonly-control i { color: var(--brand); }

.table { border-color: var(--line); color: var(--text); margin-bottom: 0; vertical-align: middle; }
.table thead th {
  background: rgba(15, 23, 42, .035);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 13px 12px;
  text-transform: uppercase;
}

[data-bs-theme="dark"] .table thead th { background: rgba(255, 255, 255, .04); }
.table tbody td,
.table tbody th {
  border: 1px solid var(--line);
  padding: 13px 12px;
}
.table-bordered { border-color: var(--line); }
.daily-log-scope-row { align-items: end; }
.daily-log-table th,
.daily-log-table td { border: 1px solid var(--line) !important; }
.daily-log-table tbody th {
  background: rgba(37, 99, 235, .04);
  font-weight: 800;
}
.action-cell .btn,
td .btn-sm { margin: 2px; }

.badge { border-radius: 999px; font-weight: 800; padding: .45rem .68rem; }
.status-draft { background: #64748b; }
.status-pending-approval { background: #f97316; }
.status-approved { background: #16a34a; }
.status-rejected { background: #dc2626; }
.permission-check {
  align-items: center;
  background: rgba(37, 99, 235, .05);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  font-size: .88rem;
  gap: 8px;
  min-height: 42px;
  padding: 9px 11px;
}

.dataTables_wrapper,
.dataTables_wrapper .dataTables_scroll,
.dataTables_wrapper table.dataTable { width: 100% !important; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  margin-left: 6px;
  padding: 6px 32px 6px 12px;
  overflow: visible !important;
  appearance: auto !important;
  -webkit-appearance: auto !important;
  -moz-appearance: auto !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  min-height: 38px;
  font-size: .85rem;
  font-weight: 600;
  background-color: var(--card-solid) !important;
  color: var(--text) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  background-size: 12px !important;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.dataTables_wrapper .dataTables_length select:hover {
  border-color: rgba(37, 99, 235, .45) !important;
}
.dataTables_wrapper .dataTables_length select:focus {
  border-color: rgba(37, 99, 235, .55) !important;
  box-shadow: 0 0 0 .25rem rgba(37, 99, 235, .12) !important;
  outline: none !important;
}
.dataTables_wrapper .dataTables_length {
  overflow: visible !important;
  position: relative;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
}
.dataTables_wrapper .dataTables_length select::-ms-expand {
  display: block !important;
}
.dataTables_wrapper .dataTables_length select option {
  color: #1e293b;
  background: #fff;
  padding: 6px 10px;
}
.dataTables_wrapper .dataTables_filter input {
  border-radius: 10px !important;
  padding: 6px 14px;
  min-height: 38px;
  font-size: .85rem;
}
.dataTables_wrapper .dataTables_filter input:focus {
  border-color: rgba(37, 99, 235, .55) !important;
  box-shadow: 0 0 0 .25rem rgba(37, 99, 235, .12) !important;
  outline: none !important;
}
.dataTables_wrapper .dt-search input,
.dataTables_wrapper .dt-length select {
  border-radius: 10px !important;
}

.login-body {
  align-items: center;
  background:
    radial-gradient(circle at 15% 10%, rgba(37, 99, 235, .22), transparent 28rem),
    radial-gradient(circle at 85% 20%, rgba(6, 182, 212, .20), transparent 28rem),
    linear-gradient(135deg, #0f172a, #1e293b);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 28px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .24);
  max-width: 430px;
  padding: 34px;
  width: 100%;
}

.login-card .brand-box { color: #0f172a; padding: 0; }
.login-card .brand-box span { color: #64748b; }

.jodit-container { border-color: var(--line) !important; border-radius: 14px !important; overflow: hidden; }
.jodit-toolbar__box { background: var(--card-solid) !important; border-color: var(--line) !important; }
.jodit-wysiwyg { min-height: 160px !important; }
.virtual-select-holder { width: 100%; }
.virtual-select-holder.is-invalid .vscomp-toggle-button { border-color: #dc3545 !important; }
.virtual-select-mirror { display: none !important; }
.vscomp-wrapper { color: var(--text); font-family: inherit; }
.vscomp-dropbox { border: 1px solid var(--line) !important; border-radius: 16px !important; box-shadow: var(--shadow-soft) !important; }

@media (max-width: 991.98px) {
  .erp-shell { display: block; }
  .erp-main { margin-left: 0; }

  /* Fixed single-row mobile header (55-60px) */
  .erp-topbar {
    height: 58px;
    padding: 0 12px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
    background: rgba(255, 255, 255, .95);
  }
  [data-bs-theme="dark"] .erp-topbar { background: rgba(17, 24, 39, .95); }

  /* Hamburger + logo on the left */
  .sidebar-toggle { display: flex; }
  .topbar-brand { display: flex; }
  .topbar-center h1 { font-size: 1.05rem; }

  /* Compact right-side actions */
  .topbar-right .user-chip { display: none; }
  .topbar-right .btn-outline-danger { padding: 4px 10px; font-size: .8rem; }

  /* Push content below fixed header */
  .erp-content { padding: 16px; padding-top: 74px; }

  /* Sidebar slides in from left, overlays everything */
  .erp-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 286px;
    max-width: 85vw;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform .28s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .erp-sidebar.open { transform: translateX(0); }

  /* Close button visible inside sidebar header on mobile */
  .sidebar-close { display: flex; }

  .hero-panel,
  .section-heading { align-items: flex-start; flex-direction: column; }
  .active-session-card { width: 100%; }
}

@media (max-width: 575.98px) {
  .panel,
  .hero-panel { padding: 16px; }
  .login-card { padding: 24px; }
  .erp-topbar .d-flex { flex-wrap: nowrap; }
  .table-responsive { border-radius: 16px; }
  .topbar-app-name { display: none; }
  .topbar-center h1 { font-size: .95rem; }
}

@media (max-width: 360px) {
  .erp-topbar { padding: 0 8px; }
  .erp-content { padding: 12px; padding-top: 70px; }
  .topbar-right { gap: 6px !important; }
}
