:root {
  --ink: #213c33;
  --green: #205b43;
  --accent: #dcf3b6;
  --muted: #75827b;
  --line: #e4e9e3;
  --bg: #f5f7f3;
  --amber: #a16922;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
}

button, a, summary {
  touch-action: manipulation;
}

a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 3px solid #8eb861;
  outline-offset: 3px;
}

h1, h2, h3, h4, p {
  margin-top: 0;
}

h1 {
  font-size: clamp(22px, 3.8vw, 30px);
  line-height: 1.25;
  letter-spacing: -0.8px;
  margin: 8px 0 10px;
  font-weight: 700;
}

h2 {
  font-size: clamp(16px, 2.5vw, 19px);
  letter-spacing: -0.3px;
  margin: 5px 0 14px;
  font-weight: 650;
}

h3 {
  font-size: 14px;
  margin-top: 20px;
  font-weight: 600;
}

p {
  line-height: 1.65;
}

small, .small {
  font-size: 12px;
}

small {
  display: block;
}

.muted {
  color: var(--muted);
}

.eyebrow, .nav-caption {
  font-size: 10px;
  letter-spacing: 1.8px;
  font-weight: 700;
  text-transform: uppercase;
}

.eyebrow {
  color: #73866e;
}

/* ========================================================
   SIDEBAR & DRAWER NAVIGATION
   ======================================================== */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  background: #123e2f;
  color: #dbe6dc;
  padding: 24px 18px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1000;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  color: inherit;
}

.brandmark {
  background: #d7edba;
  color: #174332;
  border-radius: 14px 3px 14px 3px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 42px;
  font-size: 22px;
  flex-shrink: 0;
}

.brand-sub {
  display: block;
  font-size: 8px;
  letter-spacing: 1.8px;
  margin-top: 3px;
  font-weight: 500;
}

.sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #dbe6dc;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.workspace {
  margin: 24px 3px 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #36614f;
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: 12px;
}

.workspace small {
  margin-left: auto;
  color: #b6cbb9;
}

.green-dot {
  width: 7px;
  height: 7px;
  border-radius: 100%;
  background: #9aba7a;
  display: inline-block;
  flex-shrink: 0;
}

.nav-caption {
  color: #9cb6a3;
  margin: 22px 10px 8px;
  font-size: 9px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 6px;
  line-height: 1.4;
  font-size: 12.5px;
  margin: 2px 0;
  transition: background 0.15s;
  min-height: 38px;
  box-sizing: border-box;
}

.sidebar nav a:hover {
  background: #244f3f;
}

.sidebar nav .active {
  color: #173d2d;
  background: #e0efc6;
  font-weight: 600;
}

.sidebar nav a > span {
  width: 20px;
  flex-shrink: 0;
  font-size: 17px;
  display: inline-flex;
  justify-content: center;
}

.sidebar nav .code-dot {
  font-size: 8px;
  border: 1px solid #799583;
  border-radius: 4px;
  text-align: center;
  line-height: 18px;
}

.nav-empty {
  color: #9fb7a7;
  font-size: 11px;
  margin: 8px 10px;
}

.sidebar-bottom {
  margin: 28px 10px 8px;
  color: #a7bcac;
  font-size: 10px;
  line-height: 1.8;
}

.sidebar-bottom small {
  font-size: 9px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 990;
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* ========================================================
   SHELL & TOPBAR
   ======================================================== */
.shell {
  margin-left: 250px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.28s ease;
  width: calc(100% - 250px);
  max-width: 100%;
}

.topbar {
  height: 72px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 800;
}

.topbar-left {
  display: none;
  align-items: center;
  gap: 12px;
}

.sidebar-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.sidebar-toggle-btn:hover {
  background: #e2e8f0;
}

.brand-mobile {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: #123e2f;
  text-decoration: none;
}

.brandmark-sm {
  background: #d7edba;
  color: #174332;
  border-radius: 8px 2px 8px 2px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.brand-mobile-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-mobile-text small {
  font-size: 9px;
  letter-spacing: 1px;
  opacity: 0.8;
  display: inline;
}

.global-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(510px, 50%);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 2px 10px;
}

.global-search input {
  border: 0;
  background: transparent;
  outline: none;
  margin: 0;
  padding: 8px 0;
  font-size: 13px;
  width: 100%;
}

.global-search > span {
  font-size: 18px;
  color: #64748b;
  flex-shrink: 0;
}

.global-search kbd {
  color: #94a3b8;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 8px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  flex-shrink: 0;
}

.user-menu small {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e8eddf;
  font-weight: 700;
  color: var(--green);
  flex-shrink: 0;
}

.user-menu details {
  position: relative;
}

.dropdown {
  position: absolute;
  right: 0;
  top: 36px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 14px;
  z-index: 1000;
  width: 180px;
  box-shadow: 0 12px 28px rgba(18, 62, 47, 0.15);
  border-radius: 8px;
}

.dropdown a {
  display: block;
  padding: 6px 0;
  font-weight: 500;
}

.dropdown button {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
}

.dropdown button:hover {
  background: #fee2e2;
}

/* ========================================================
   MAIN CONTENT & LAYOUTS
   ======================================================== */
main {
  padding: 28px 32px 40px;
  min-height: calc(100vh - 120px);
  max-width: 1700px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  flex: 1;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 6px 0 20px;
  flex-wrap: wrap;
}

.page-heading p {
  margin: 0;
  font-size: 13px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #d9e1d8;
  background: white;
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s;
  min-height: 38px;
  box-sizing: border-box;
}

.button:hover {
  background: #edf2e9;
}

.button.primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.button.primary:hover {
  background: #164e37;
}

.button.danger {
  background: #b23b2b;
  color: #fff;
  border-color: #b23b2b;
}

.button.danger:hover {
  background: #8f281b;
}

.button.small {
  padding: 5px 10px;
  font-size: 11px;
  min-height: 30px;
}

.full {
  width: 100%;
}

.scope-note {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 16px 0 20px;
  color: #788576;
  font-size: 11px;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 18px 0 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  padding: 18px 20px;
  border-radius: 9px;
  transition: transform 0.2s, box-shadow 0.2s;
  min-width: 0;
  display: block;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.stat-card > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #65776b;
}

.stat-card b {
  font-size: 18px;
  color: #5d876a;
}

.stat-card > strong {
  display: block;
  font-size: clamp(22px, 3.5vw, 34px);
  line-height: 1.35;
  letter-spacing: -0.8px;
  font-weight: 600;
  margin: 12px 0 4px;
  overflow-wrap: anywhere;
}

.stat-card small {
  color: #879083;
  font-size: 10px;
}

.money-stats .stat-card > strong {
  font-size: clamp(16px, 2vw, 26px);
  overflow-wrap: anywhere;
}

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 22px;
  margin-bottom: 22px;
  min-width: 0;
  box-sizing: border-box;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.panel-heading h2 {
  margin-bottom: 4px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 22px;
}

.text-link {
  color: #467653;
  font-size: 12px;
  font-weight: 600;
}

.text-link:hover {
  text-decoration: underline;
}

.division-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
}

.division-row > div {
  flex: 1;
  min-width: 0;
}

.division-row strong {
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.division-row > b {
  font-size: 14px;
  margin-left: 10px;
  width: 25px;
  text-align: right;
  flex-shrink: 0;
}

.division-icon {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background: #eff4e8;
  display: grid;
  place-items: center;
  color: #4d7251;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.bar-track {
  height: 4px;
  background: #eff2eb;
  margin-top: 8px;
  border-radius: 6px;
  overflow: hidden;
}

.bar-track > span {
  display: block;
  height: 100%;
  background: #88a66b;
  border-radius: 6px;
}

.division-row:nth-child(odd) .bar-track > span {
  background: #406e50;
}

.attention {
  background: #fbfcf8;
}

.amber, .amber-circle {
  color: var(--amber) !important;
}

.amber-circle {
  border: 1px solid #e1d6b9;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  text-align: center;
  line-height: 24px;
  flex-shrink: 0;
}

.attention-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.attention-item > strong {
  font-size: 24px;
  min-width: 28px;
  flex-shrink: 0;
}

.attention-item > div {
  flex: 1;
  min-width: 0;
}

.attention-item b {
  font-size: 12px;
  font-weight: 600;
}

.attention-item small {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

.note {
  background: #f0f3e8;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 11.5px;
  line-height: 1.65;
  color: #6b775f;
  margin-top: 18px;
}

.row-between {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: center;
  margin: 8px 0;
  flex-wrap: wrap;
}

/* ========================================================
   TABLES & RESPONSIVE SCROLL
   ======================================================== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  margin: 10px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
  min-width: 540px;
}

th {
  font-size: 10px;
  color: #7b897c;
  font-weight: 600;
  background: #f8faf5;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 14px 10px;
  border-bottom: 1px solid #edf0e9;
  line-height: 1.55;
  vertical-align: middle;
}

td small {
  font-size: 10px;
  color: #859080;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.table-plain {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.table-plain tr {
  border-bottom: 1px solid var(--line);
}

.table-plain td {
  padding: 12px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-plain td:first-child {
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
}

.doc-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  font-weight: 600;
  min-width: 0;
}

.file-icon {
  background: #eff4ea;
  color: #617c55;
  width: 32px;
  height: 36px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 16px;
}

.badge {
  display: inline-block;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 9.5px;
  background: #eef1eb;
  color: #657561;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge.approved {
  background: #e7f1de;
  color: #52723b;
}

.badge.review {
  background: #faf0d7;
  color: #9e782a;
}

.badge.archived {
  background: #e7eae7;
  color: #6c766c;
}

.badge.danger {
  background: #fee2e2;
  color: #b91c1c;
}

.nowrap {
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ========================================================
   FORMS & INPUTS
   ======================================================== */
.filter-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #526951;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  margin-bottom: 12px;
  padding: 9px 11px;
  border: 1px solid #dbe3d7;
  border-radius: 6px;
  color: var(--ink);
  background: white;
  min-width: 0;
  box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid #a2b48d;
  outline-offset: 1px;
}

select[multiple] {
  min-height: 95px;
}

input[type=checkbox] {
  width: auto;
  display: inline;
  margin: 4px 7px 4px 0;
}

.filter-form input, .filter-form select {
  margin-bottom: 0;
}

.filter-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 12px;
  padding: 18px 0 0;
  flex-wrap: wrap;
  align-items: center;
}

.form-panel {
  max-width: 850px;
}

.form-panel form > p {
  margin-bottom: 20px;
}

.helptext {
  font-size: 11px;
  color: var(--muted);
}

.errorlist {
  list-style: none;
  padding: 10px 14px;
  background: #fff0eb;
  color: #9c4530;
  border-radius: 6px;
  font-size: 12px;
  margin: 8px 0;
}

/* ========================================================
   DOCUMENT DETAIL PAGE
   ======================================================== */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 22px;
}

.version {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.version strong {
  overflow-wrap: anywhere;
}

.version p {
  margin: 4px 0;
}

.hash {
  font-size: 9px;
  color: #8c9587;
  overflow-wrap: anywhere;
  margin-top: 8px;
}

dl {
  display: grid;
  grid-template-columns: 150px 1fr;
  font-size: 12px;
  gap: 12px;
}

dt {
  color: #7d8879;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.tag-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.tag-card {
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 6px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tag-card:hover {
  border-color: #8fa57e;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.tag-info {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  flex: 1;
}

.tag-info strong {
  font-size: 12px;
  color: #2c4c34;
  font-weight: 600;
}

.tag-info small {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.tag-delete-btn {
  background: none;
  border: none;
  color: #b23b2b;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
}

.tag-delete-btn:hover {
  opacity: 1;
  background: #fee8e6;
}

.tag-select-checkbox {
  cursor: pointer;
  accent-color: #2f4e37;
  margin: 0;
}

.timeline {
  border-left: 2px solid #dfe8d6;
  margin: 18px 0;
  padding-left: 14px;
  font-size: 11px;
}

.timeline strong {
  font-weight: 600;
}

.timeline small {
  font-size: 10px;
  color: var(--muted);
  margin: 5px 0;
}

.timeline p {
  font-size: 11px;
  overflow-wrap: anywhere;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.collection-card {
  margin: 0;
}

.collection-card h2 {
  margin-top: 16px;
}

.collection-card p {
  color: var(--muted);
  font-size: 12px;
}

.collection-card:hover {
  border-color: #8fa57e;
}

.list-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

summary {
  cursor: pointer;
  font-size: 12px;
  margin: 10px 0;
}

details form {
  padding-top: 10px;
}

.filter-popover {
  border: 1px solid var(--line);
  padding: 14px;
  background: #fff;
  border-radius: 8px;
}

.ocr-text {
  white-space: pre-wrap;
  max-height: 280px;
  overflow: auto;
  background: #f5f7f0;
  padding: 12px;
  font-size: 11.5px;
  border-radius: 6px;
}

.empty {
  text-align: center;
  padding: 40px 15px;
  color: #83907c;
}

.empty > span {
  font-size: 32px;
}

.empty h3 {
  margin-top: 12px;
}

.message {
  padding: 12px 16px;
  background: #e8f1df;
  border: 1px solid #d5e1c9;
  margin-bottom: 14px;
  border-radius: 6px;
  font-size: 12.5px;
}

.message.error {
  background: #fff0e6;
  border-color: #ebcbbb;
  color: #9c4530;
}

.demo {
  padding: 8px 12px;
  background: #f8efd9;
  color: #927231;
  font-size: 10.5px;
  border-radius: 5px;
  margin-bottom: 16px;
  letter-spacing: 0.3px;
}

footer {
  padding: 14px 32px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: #8c9788;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}

legend {
  font-weight: 600;
  padding: 0 8px;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.search-hit {
  background: #ffe47d;
  color: #30270b;
  padding: 1px 3px;
  border-radius: 2px;
}

.search-excerpt {
  margin: 8px 0 0 44px;
  max-width: 620px;
}

.search-excerpt p {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.search-excerpt small {
  color: #65776b;
  font-size: 10px;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -4px 0 16px;
  font-size: 12px;
}

.filter-chip {
  background: #e5efdf;
  border: 1px solid #c9d9bf;
  border-radius: 20px;
  padding: 6px 11px;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.filter-chip:hover {
  background: #d7e8cd;
}

.search-help {
  color: #65776b;
  font-size: 11px;
  line-height: 1.6;
  margin-bottom: 16px;
}

/* ========================================================
   LOGIN PAGE
   ======================================================== */
.login-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  background: #fafbf6;
}

.login-story {
  background: #133f30;
  color: #e1edd6;
  padding: 50px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  box-sizing: border-box;
}

.login-story h1 {
  font-size: clamp(32px, 4.5vw, 52px);
  line-height: 1.18;
  font-weight: 600;
  letter-spacing: -1.5px;
  margin: 20px 0;
}

.login-story p {
  font-size: 14px;
  color: #abc3ae;
  line-height: 1.6;
}

.login-story .eyebrow {
  color: #b4cea0;
}

.login-form {
  align-self: center;
  margin: 40px auto;
  width: 75%;
  max-width: 410px;
  box-sizing: border-box;
}

.login-form h2 {
  font-size: 26px;
  margin-top: 14px;
}

.login-form form {
  margin: 24px 0;
}

.login-form input {
  padding: 12px;
}

.login-form button {
  padding: 13px;
  font-size: 14px;
}

.check {
  display: flex;
  align-items: center;
}

.login-story small {
  color: #a6bba5;
}

/* ========================================================
   PAPERLESS-NGX STYLE REPOSITORY VIEW
   ======================================================== */
.documents-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}

.header-titles .eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted, #64748b);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 3px;
}

.title-with-count {
  display: flex;
  align-items: center;
  gap: 12px;
}

.title-with-count h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
}

.count-pill {
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
}

.header-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.view-switcher-group {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.view-btn {
  background: none;
  border: none;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  min-height: 32px;
}

.view-btn:hover {
  color: #0f172a;
}

.view-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.quick-select-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
}

.btn-text-action {
  background: none;
  border: 1px solid #cbd5e1;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  min-height: 28px;
}

.btn-text-action:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.sort-form-inline .select-sort {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  font-size: 12px;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  margin: 0;
  min-height: 34px;
}

.upload-btn {
  font-size: 13px;
  font-weight: 600;
  padding: 7px 15px;
}

/* Paperless Filter Bar */
.paperless-filter-bar {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.p-filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-pill {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
}

.search-pill {
  flex: 1 1 240px;
  min-width: 180px;
}

.pill-icon {
  padding: 0 8px;
  font-size: 13px;
  color: #64748b;
}

.pill-search-input {
  border: none;
  background: transparent;
  padding: 7px 8px 7px 0;
  font-size: 13px;
  width: 100%;
  outline: none;
  margin: 0;
}

.pill-submit-btn {
  background: #2f4e37;
  color: #ffffff;
  border: none;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.filter-dropdown {
  position: relative;
  display: inline-block;
}

.filter-dropdown-btn {
  list-style: none;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  transition: all 0.15s ease;
  min-height: 34px;
}

.filter-dropdown-btn::-webkit-details-marker {
  display: none;
}

.filter-dropdown-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.filter-dropdown-btn.has-val {
  background: #ecfdf5;
  border-color: #10b981;
  color: #065f46;
  font-weight: 600;
}

.filter-popover-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 100;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  min-width: 220px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.12);
}

.filter-popover-menu label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.filter-popover-menu select,
.filter-popover-menu input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
  font-size: 12px;
  margin-bottom: 8px;
}

.reset-filter-btn {
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  background: #fee2e2;
  transition: background 0.15s ease;
  display: inline-flex;
  align-items: center;
}

.reset-filter-btn:hover {
  background: #fecaca;
}

/* Multi-View Visibility */
.view-mode-cards .cards-view-wrap { display: flex; flex-direction: column; gap: 12px; }
.view-mode-cards .table-view-wrap { display: none; }
.view-mode-cards .grid-view-wrap { display: none; }

.view-mode-table .cards-view-wrap { display: none; }
.view-mode-table .table-view-wrap { display: block; }
.view-mode-table .grid-view-wrap { display: none; }

.view-mode-grid .cards-view-wrap { display: none; }
.view-mode-grid .table-view-wrap { display: none; }
.view-mode-grid .grid-view-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* Paperless Card Layout */
.paperless-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  transition: all 0.15s ease;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.paperless-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.card-select {
  flex: 0 0 24px;
  padding-top: 6px;
  display: flex;
  justify-content: center;
}

.card-thumb-wrap {
  flex: 0 0 95px;
  width: 95px;
  height: 130px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
  background: #f8fafc;
  position: relative;
  flex-shrink: 0;
}

.card-thumb-link {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
}

.doc-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
  transition: transform 0.2s ease;
}

.card-thumb-link:hover .doc-thumb-img {
  transform: scale(1.03);
}

.thumb-ext-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 3px;
  color: #ffffff;
  background: #475569;
}

/* Extension Badges */
.ext-pdf { background-color: #e11d48 !important; }
.ext-xlsx, .ext-xls, .ext-csv { background-color: #059669 !important; }
.ext-docx, .ext-doc { background-color: #2563eb !important; }
.ext-pptx, .ext-ppt { background-color: #ea580c !important; }
.ext-geojson, .ext-shp { background-color: #0d9488 !important; }
.ext-zip { background-color: #4f46e5 !important; }
.ext-txt { background-color: #475569 !important; }

/* Card Content */
.card-main {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  line-height: 1.35;
}

.card-title a {
  color: #0f172a;
  text-decoration: none;
}

.card-title a:hover {
  color: #0284c7;
  text-decoration: underline;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge-pill {
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
}

.col-pill {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #dbeafe;
}

.type-pill {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.card-code-line {
  font-size: 12px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.doc-code-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: #475569;
}

.card-snippet {
  background: #f8fafc;
  border-left: 3px solid #cbd5e1;
  padding: 6px 12px;
  border-radius: 0 4px 4px 0;
  margin: 4px 0;
}

.card-snippet p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #334155;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.p-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #334155;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}

.p-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.card-aside {
  flex: 0 0 140px;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
  margin-left: auto;
}

.aside-date, .aside-size, .aside-entities {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Grid View */
.doc-grid-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.15s ease;
}

.doc-grid-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: #cbd5e1;
}

.grid-thumb-box {
  width: 100%;
  height: 170px;
  background: #f8fafc;
  position: relative;
  overflow: hidden;
}

.grid-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.grid-ext-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  color: #ffffff;
}

.grid-select-wrap {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(255,255,255,0.88);
  border-radius: 4px;
  padding: 2px 5px;
}

.grid-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.grid-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
}

.grid-title a {
  color: #0f172a;
  text-decoration: none;
}

.grid-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #64748b;
  flex-wrap: wrap;
}

.grid-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
}

.p-btn-sm {
  flex: 1;
  text-align: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 500;
  color: #334155;
  text-decoration: none;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.p-btn-sm:hover {
  background: #e2e8f0;
}

/* ========================================================
   MODERN DOCUMENT UPLOAD & DRAG-AND-DROP WORKFLOW
   ======================================================== */
.upload-page-shell {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.upload-master-form {
  width: 100%;
  box-sizing: border-box;
}

.upload-drop-panel,
.upload-meta-panel {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden;
}

.collection-select-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 4px 12px;
  margin-top: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.col-bar-icon {
  font-size: 15px;
}

.col-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.col-select-dropdown {
  border: none !important;
  background: transparent !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  color: #0f172a !important;
  padding: 2px 20px 2px 0 !important;
  margin: 0 !important;
  cursor: pointer;
  outline: none !important;
}

.upload-drop-panel {
  margin-bottom: 24px;
  padding: 24px;
}

.upload-dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  background: #f8fafc;
  padding: 38px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: #205b43;
  background: #f0fdf4;
}

.drop-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #e8f5ed;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: #205b43;
  margin-bottom: 12px;
}

.upload-dropzone h3 {
  margin: 0 0 6px 0;
  font-size: 17px;
  color: #0f172a;
}

.dropzone-hint {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 16px 0;
  line-height: 1.5;
}

.dropzone-hint strong {
  color: #334155;
}

.btn-browse-files {
  background: #205b43;
  color: #ffffff;
  border: 1px solid #205b43;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 5px rgba(32, 91, 67, 0.2);
}

.btn-browse-files:hover {
  background: #164332;
  box-shadow: 0 4px 10px rgba(32, 91, 67, 0.3);
}

/* File Queue */
.file-queue-section {
  margin-top: 22px;
  border-top: 1px solid #e2e8f0;
  padding-top: 16px;
}

.queue-header {
  margin-bottom: 12px;
}

.queue-header h4 {
  margin: 0 0 4px 0;
  font-size: 15px;
  color: #0f172a;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.queue-ext-badge {
  flex: 0 0 46px;
  text-align: center;
  padding: 6px 0;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  background: #475569;
}

.queue-meta-file {
  flex: 0 0 170px;
  min-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-meta-file strong {
  display: block;
  font-size: 12px;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-meta-file small {
  font-size: 11px;
  color: #64748b;
}

.queue-title-input {
  flex: 1 1 200px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  margin: 0;
}

.queue-date-input {
  flex: 0 0 140px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12px;
  margin: 0;
}

.queue-remove-btn {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
}

.queue-remove-btn:hover {
  background: #fee2e2;
}

/* Metadata Layout */
.upload-meta-panel {
  padding: 24px 28px;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.meta-grid-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}

.meta-col-left,
.meta-col-right {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sub-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.sub-panel:last-child {
  margin-bottom: 0;
}

.subpanel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
}

.subpanel-title span {
  font-size: 16px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
  display: block;
}

.form-group input, 
.form-group select, 
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 13px;
  color: #0f172a;
  box-sizing: border-box;
  margin-top: 4px;
  margin-bottom: 4px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
  border-color: #205b43;
  outline: none;
  box-shadow: 0 0 0 3px rgba(32, 91, 67, 0.12);
}

.form-group small.muted {
  font-size: 11px;
  color: #64748b;
  display: block;
  margin-top: 2px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.activity-subpanel .activity-select {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 13px;
  color: #0f172a;
  font-weight: 500;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.location-input {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  font-size: 13px;
  box-sizing: border-box !important;
}

/* Entity Searchable Picker */
.entity-kind-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.tab-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 5px 11px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  min-height: 30px;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  background: #f1f5f9;
}

.tab-btn.active {
  background: #205b43;
  color: #ffffff;
  border-color: #205b43;
}

.entity-search-box {
  margin-bottom: 10px;
}

.entity-search-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12.5px;
  box-sizing: border-box;
  margin: 0;
}

.selected-entities-wrap {
  margin-bottom: 10px;
  display: none;
}

.selected-entities-wrap.has-items {
  display: block;
}

.selected-label {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  display: block;
  margin-bottom: 4px;
}

.entity-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.e-chip {
  background: #ecfdf5;
  border: 1px solid #10b981;
  color: #065f46;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.e-chip-remove {
  cursor: pointer;
  font-weight: 700;
  color: #ef4444;
}

.entity-scroll-list {
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  width: 100%;
  box-sizing: border-box;
}

.entity-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.1s;
  min-height: 36px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.entity-item-row:hover {
  background: #f8fafc;
}

.entity-item-row:last-child {
  border-bottom: none;
}

.e-badge {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  color: #ffffff;
}

.e-akkm { background: #059669; }
.e-pemangku { background: #2563eb; }
.e-code { flex-shrink: 0; font-weight: 600; color: #0f172a; }
.e-name {
  flex: 1;
  min-width: 0;
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.e-loc {
  font-size: 11px;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 155px;
  flex-shrink: 0;
}

.entity-location-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 10px;
  font-size: 11.5px;
  color: #166534;
}

.loc-filter-text {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-filter-icon {
  font-size: 13px;
}

.loc-filter-toggle-btn {
  background: #ffffff;
  border: 1px solid #86efac;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #166534;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.loc-filter-toggle-btn:hover {
  background: #dcfce7;
}

.loc-filter-toggle-btn.bypassed {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

/* Tags picker */
.tags-picker-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-pick-label {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  min-height: 32px;
  transition: all 0.15s ease;
}

.tag-pick-label:hover {
  border-color: #205b43;
}

.upload-actions-bar {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-upload-submit {
  background: #205b43;
  color: #ffffff;
  border: 1px solid #205b43;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(32, 91, 67, 0.2);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-upload-submit:hover {
  background: #164332;
  box-shadow: 0 4px 12px rgba(32, 91, 67, 0.3);
}

.btn-upload-cancel {
  background: #ffffff;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-upload-cancel:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

/* ========================================================
   COMPREHENSIVE RESPONSIVE MEDIA QUERIES
   ======================================================== */

/* 1. Large Desktops & Tablets Landscape (<= 1200px) */
@media (max-width: 1200px) {
  .sidebar { width: 220px; }
  .shell { margin-left: 220px; width: calc(100% - 220px); }
  main { padding: 24px; }
  .topbar { padding: 0 24px; }
  .filter-form { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { gap: 16px; }
  .detail-grid { grid-template-columns: 1.2fr 1fr; }
}

/* 2. Tablets & Mobile Landscape (<= 900px) - Mobile Drawer Navigation */
@media (max-width: 900px) {
  .sidebar {
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 1200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  }
  .sidebar-close-btn {
    display: flex;
  }
  .sidebar-backdrop {
    display: block;
    pointer-events: none;
  }
  .sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }
  body.sidebar-locked {
    overflow: hidden;
  }
  .shell {
    margin-left: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  .topbar {
    height: 60px;
    padding: 0 16px;
    gap: 12px;
  }
  .topbar-left {
    display: flex;
  }
  .sidebar-toggle-btn {
    display: flex;
  }
  .brand-mobile {
    display: flex;
  }
  .global-search {
    width: auto;
    flex: 1 1 auto;
    max-width: 340px;
  }
  .global-search kbd {
    display: none;
  }
  .dashboard-grid, .detail-grid, .meta-grid-layout {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .collection-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 3. Phablets & Mobile Devices (<= 768px) */
@media (max-width: 768px) {
  /* Prevent iOS Safari automatic zooming on input focus */
  input, select, textarea {
    font-size: 16px !important;
  }

  main {
    padding: 16px 14px 32px;
  }

  .page-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-heading > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .page-heading .button {
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
  }
  .actions {
    width: 100%;
  }
  .actions .button {
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
  }

  /* Paperless Cards on Tablet/Mobile */
  .paperless-card {
    padding: 12px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .card-select {
    flex: 0 0 20px;
    padding-top: 2px;
  }
  .card-thumb-wrap {
    flex: 0 0 74px;
    width: 74px;
    height: 102px;
  }
  .card-main {
    flex: 1 1 calc(100% - 110px);
    min-width: 0;
  }
  .card-title {
    font-size: 14px;
  }
  .card-aside {
    flex: 1 1 100%;
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-left: 0;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
    font-size: 11px;
  }
  .card-actions-bar {
    margin-top: 8px;
    width: 100%;
  }
  .card-actions-bar .p-btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 6px 10px;
    font-size: 11.5px;
  }

  /* Repository Filter Bar */
  .documents-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .header-controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .view-switcher-group {
    width: 100%;
  }
  .view-btn {
    flex: 1;
    justify-content: center;
  }
  .quick-select-group {
    width: 100%;
    justify-content: flex-start;
  }
  .sort-form-inline {
    width: 100%;
  }
  .select-sort {
    width: 100%;
    box-sizing: border-box;
  }
  .upload-btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
  .paperless-filter-bar {
    padding: 8px 10px;
  }
  .search-pill {
    flex: 1 1 100%;
    width: 100%;
  }
  .filter-popover-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 16px;
    width: auto;
    max-width: calc(100vw - 24px);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 1300;
    border-radius: 12px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.25);
  }

  /* File Queue Item Stacked Layout */
  .queue-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
  }
  .queue-meta-file {
    flex: 1 1 100%;
    width: 100%;
  }
  .queue-title-input {
    flex: 1 1 100%;
    width: 100%;
    box-sizing: border-box;
  }
  .queue-date-input {
    flex: 1 1 100%;
    width: 100%;
    box-sizing: border-box;
  }

  /* Filter form */
  .filter-form {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Login page stacked */
  .login-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }
  .login-story {
    min-height: auto;
    padding: 30px 20px 24px;
    gap: 16px;
  }
  .login-story h1 {
    font-size: 28px;
    line-height: 1.25;
    margin: 12px 0 8px;
  }
  .login-story p {
    font-size: 13px;
    line-height: 1.5;
    display: block;
  }
  .login-form {
    width: 100%;
    max-width: 100%;
    padding: 24px 20px 48px;
    margin: 0 auto;
    box-sizing: border-box;
  }
}

/* 4. Small Phones (<= 540px) */
@media (max-width: 540px) {
  .topbar {
    padding: 0 10px;
    height: 56px;
  }
  .brand-mobile-text {
    display: none;
  }
  .user-menu > div {
    display: none;
  }
  .global-search input {
    font-size: 12.5px;
    padding: 6px 0;
  }
  .panel {
    padding: 15px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .stat-card {
    padding: 12px 14px;
  }
  .stat-card > div {
    font-size: 11px;
  }
  .stat-card > strong {
    font-size: clamp(18px, 5.5vw, 24px);
    margin: 8px 0 4px;
  }
  .stat-card small {
    font-size: 9px;
  }
  .collection-grid {
    grid-template-columns: 1fr;
  }

  /* Detail definition list single-column stack */
  dl {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  dt {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
  }
  dd {
    font-size: 13.5px;
    margin-bottom: 6px;
  }

  /* Two-column grid view on small screens */
  .view-mode-grid .grid-view-wrap {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .grid-thumb-box {
    height: 130px;
  }
  .grid-card-body {
    padding: 8px;
    gap: 4px;
  }
  .grid-title {
    font-size: 12px;
  }
  .grid-meta {
    font-size: 10px;
  }
  .grid-actions {
    flex-direction: column;
    gap: 4px;
  }

  /* Forms & Upload */
  .form-row-2 {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .upload-drop-panel {
    padding: 14px;
    margin-bottom: 14px;
  }
  .upload-meta-panel {
    padding: 16px 14px;
    margin-bottom: 16px;
  }
  .sub-panel {
    padding: 14px 12px;
  }
  .upload-dropzone {
    padding: 20px 12px;
  }
  .drop-icon-wrap {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
  .upload-dropzone h3 {
    font-size: 15px;
  }
  .dropzone-hint {
    font-size: 12px;
    margin-bottom: 12px;
  }
  .queue-item {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 10px;
  }
  .queue-meta-file {
    flex: 1 1 calc(100% - 60px);
  }
  .queue-title-input {
    flex: 1 1 100%;
    width: 100%;
  }
  .queue-date-input {
    flex: 1 1 calc(100% - 44px);
  }
  .tab-btn {
    flex: 1 1 auto;
    text-align: center;
  }
  .upload-actions-bar {
    flex-direction: column-reverse;
    gap: 10px;
    width: 100%;
  }
  .upload-actions-bar .button {
    width: 100%;
    justify-content: center;
  }
  .filter-form {
    grid-template-columns: 1fr;
  }
  .filter-actions {
    flex-direction: column;
  }
  .filter-actions .button {
    width: 100%;
    justify-content: center;
  }
  footer {
    padding: 14px 16px;
    flex-direction: column;
    text-align: center;
    gap: 6px;
  }
}

/* ========================================================
   MOBILE BOTTOM APP NAVIGATION BAR (CENTER DOCKED / FLOATING)
   ======================================================== */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 820px) {
  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .mobile-bottom-nav {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 520px;
    margin: 0 auto;
    gap: 2px;
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    padding: 4px 2px;
    border-radius: 10px;
    text-decoration: none;
    color: #64748b;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-item:active {
    transform: scale(0.92);
  }

  .mobile-nav-icon {
    font-size: 19px;
    line-height: 1.1;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
  }

  .mobile-nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .mobile-nav-item.active {
    color: #0f766e;
    font-weight: 700;
  }

  .mobile-nav-item.active .mobile-nav-icon {
    transform: scale(1.12);
  }

  .mobile-nav-item.active .mobile-nav-label {
    color: #0f766e;
    font-weight: 700;
  }
}

/* Tablet floating pill style (541px - 820px) */
@media (min-width: 541px) and (max-width: 820px) {
  .mobile-bottom-nav {
    bottom: 12px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 480px;
    border-radius: 28px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15), 0 2px 6px rgba(0,0,0,0.06);
    padding: 6px 12px;
  }
}

/* ========================================================
   RESPONSIVE TABLE HORIZONTAL TOUCH SCROLL & HINTS
   ======================================================== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  position: relative;
  border-radius: 8px;
}

@media (max-width: 820px) {
  .table-wrap table {
    min-width: 680px;
  }
}

.mobile-table-scroll-hint {
  display: none;
}
@media (max-width: 820px) {
  .mobile-table-scroll-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: #475569;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    padding: 6px 12px;
    margin-bottom: 8px;
    line-height: 1.4;
  }
}

/* ========================================================
   RESPONSIVE DUAL-GRID & FORM UTILITIES
   ======================================================== */
.work-dual-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(320px, 1.15fr);
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .work-dual-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem;
  }
}

.settings-dual-grid {
  display: grid;
  grid-template-columns: 1.4fr 1.1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .settings-dual-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
}

.form-grid-2, .form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 640px) {
  .form-grid-2, .form-row-2 {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
}

.executive-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 1024px) {
  .executive-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}
@media (max-width: 540px) {
  .executive-kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .executive-kpi-grid .stat-card {
    padding: 14px;
  }
  .executive-kpi-grid .stat-value {
    font-size: 20px !important;
  }
}

