:root{
  /* Brand */
  --primary:#4F46E5;
  --accent:#06B6D4;

  /* Light UI */
  --bg:#F6F8FC;
  --text:#0F172A;
  --muted:#475569;
  --muted2:#64748B;

  --border:#E5E7EB;
  --shadow:0 18px 45px rgba(15,23,42,.12);

  --radius:18px; --radius2:14px; --max:1100px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}
*{box-sizing:border-box}
body{
  margin:0; font-family:var(--font); color:var(--text);
  background:
    radial-gradient(1000px 600px at 20% 0%, color-mix(in srgb, var(--primary) 14%, white), transparent 60%),
    radial-gradient(900px 500px at 90% 30%, color-mix(in srgb, var(--accent) 12%, white), transparent 55%),
    var(--bg);
}
body.modal-open{
  overflow:hidden;
  height:100%;
}
.muted{color:var(--muted)}
.small{font-size:13px}
.topbar{
  display:flex; justify-content:space-between; align-items:center; gap:16px;
  padding:18px 22px; border-bottom:1px solid var(--border);
  position:sticky; top:0;
  background:rgba(246,248,252,.82);
  backdrop-filter:blur(10px);
  z-index: 1000;
}
.brand{display:flex; align-items:center; gap:12px}
.brand__mark{
  width:42px; height:42px; border-radius:14px; display:grid; place-items:center; font-weight:800;
  background:linear-gradient(135deg, color-mix(in srgb, var(--primary) 95%, transparent), color-mix(in srgb, var(--accent) 85%, transparent));
  box-shadow:var(--shadow);

  /* make <a class="brand__mark"> look like the old div */
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand__mark:visited,
.brand__mark:hover,
.brand__mark:active,
.brand__mark:focus{
  text-decoration: none;
  color: inherit;
}

.brand__sub{color:var(--muted2); font-size:13px; margin-top:2px}
.matter{text-align:right}
.matter__ref{color:var(--muted2); font-size:13px}
.container{max-width:var(--max); margin:22px auto 60px; padding:0 18px}
.card{
  background:linear-gradient(180deg, #ffffff, #f8fafc);
  border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow);
  padding:20px; margin-bottom:18px;
}

/* Document category tiles */
.sections {
  display: flex !important;
  flex-direction: column !important;
  gap: 18px;
  margin-top: 16px;
}

.doc-tile{
  background:linear-gradient(180deg, #ffffff, #f8fafc);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
}

.doc-tile .doc-section{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.doc-section__head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
}

.doc-section__title{
  font-weight:800;
  font-size:15px;
}

.doc-section__sub{
  margin-top:4px;
}

/* Custom / user-added tiles */
.doc-tile--custom{
  border-style:dashed;
  background:color-mix(in srgb, var(--accent) 5%, white);
}

.doc-tile--user{
  border-color:color-mix(in srgb, var(--primary) 45%, var(--border));
  background:color-mix(in srgb, var(--primary) 6%, white);
}

.grid{display:grid; grid-template-columns:1.2fr .8fr; gap:18px}
@media(max-width:900px){.grid{grid-template-columns:1fr}.matter{display:none}}
.h1{margin:0 0 10px; font-size:26px}
.h2{margin:0 0 12px; font-size:16px}
.pill-row{display:flex; flex-wrap:wrap; gap:10px; margin-top:12px}
.pill{
  font-size:13px; padding:8px 10px; border-radius:999px;
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--primary) 6%, white);
}
.requirements{
  background:#ffffff;
  border:1px solid var(--border);
  border-radius:var(--radius2);
  padding:14px;
}
.req-list{list-style:none; margin:0; padding:0; display:grid; gap:10px}
.req{
  padding:10px 12px;
  border-radius:12px;
  border:1px dashed color-mix(in srgb, var(--border) 85%, #cbd5e1);
  background:color-mix(in srgb, var(--primary) 4%, white);
}
.req__detail{color:var(--muted2); font-size:13px; margin-top:4px}
.upload-area{
  position:relative;
  border-radius:var(--radius);
  border:2px dashed #cbd5e1;
  background:#ffffff;
  padding:22px;
  cursor:pointer;
  outline:none;
}

.doc-tile .upload-area{
  margin-top:4px;
}

.upload-area:hover{
  border-color:color-mix(in srgb, var(--primary) 55%, #cbd5e1);
  background:color-mix(in srgb, var(--primary) 5%, white);
}
.upload-area.is-dragover{
  border-color:color-mix(in srgb, var(--accent) 70%, #cbd5e1);
  background:color-mix(in srgb, var(--accent) 8%, white);
}
.upload-area__input{position:absolute; inset:0; opacity:0; cursor:pointer}
.upload-area__content{display:grid; place-items:center; text-align:center; gap:6px}
.actions{display:flex; align-items:center; gap:10px; margin-top:14px; flex-wrap:wrap}
.spacer{flex:1}
.status{color:var(--muted); font-size:13px}
.btn{
  border:1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  background:color-mix(in srgb, var(--primary) 10%, white);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  font-weight:650;
  cursor:pointer;
}
.btn:hover{
  border-color:color-mix(in srgb, var(--primary) 55%, var(--border));
  background:color-mix(in srgb, var(--primary) 14%, white);
}
.btn:disabled{opacity:.45; cursor:not-allowed}
.btn--secondary{
  background:#ffffff;
  border-color:var(--border);
}
.btn--danger{
  background:rgba(239,68,68,.08);
  border-color:rgba(239,68,68,.35);
  color:#991b1b;
}
.btn--danger:hover{
  background:rgba(239,68,68,.12);
  border-color:rgba(239,68,68,.45);
}
.progress-wrap{
  margin-top:14px;
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
  background:#ffffff;
}
.progress-label{display:flex; justify-content:space-between; margin-bottom:8px; color:var(--muted); font-size:13px}
progress{width:100%; height:16px}

.doc-tile .filelist{
  margin-top:10px;
}

.filelist{margin-top:14px;
 display:grid;
 gap:10px
 display:flex;
 justify-content:space-between;
 align-items:center;
 }
.file{
  border:1px solid var(--border);
  border-radius:14px;
  background:#ffffff;
  padding:12px;
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.file__left{
  flex:1 1 auto;
  min-width:0; /* ✅ critical for ellipsis inside flex */
}

.file__name{
  display:block;
  max-width:100%;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis; /* ✅ adds ... */
}

.file__right{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;
  flex-wrap:wrap
}

.file__name{font-weight:650; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.file__meta{color:var(--muted2); font-size:13px; margin-top:4px}
.file__right{display:flex; align-items:center; gap:10px}
.badge{
  font-size:12px;
  padding:6px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  color:var(--muted);
  background:color-mix(in srgb, var(--primary) 4%, white);
}
.badge--ok{border-color:rgba(34,197,94,.45); color:rgba(34,197,94,.95)}
.badge--err{border-color:rgba(255,77,109,.45); color:rgba(255,77,109,.95)}
.notice{
  margin-top:12px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid transparent;
  background:transparent;
}

/* Success */
.notice--success{
  border-color: rgba(34,197,94,.35);
  background: rgba(34,197,94,.08);
  color: #166534;
}

/* Fail / Error */
.notice--fail{
  border-color: rgba(239,68,68,.35);
  background: rgba(239,68,68,.08);
  color: #991b1b;
}
.footer{text-align:center; margin-top:10px}

/* Select dropdown styling */
select.field{
  appearance:none;
  -webkit-appearance:none;
  -moz-appearance:none;

  padding-right:40px; /* room for caret */
  cursor:pointer;
  background:
    linear-gradient(180deg, #ffffff, #f8fafc);
}

/* caret */
.select-wrap{
  position:relative;
}
.select-wrap::after{
  content:"";
  position:absolute;
  right:14px;
  top:50%;
  width:10px;
  height:10px;
  transform:translateY(-50%) rotate(45deg);
  border-right:2px solid var(--muted2);
  border-bottom:2px solid var(--muted2);
  pointer-events:none;
  opacity:.8;
}

/* Modal */
.modal{display:none}
.modal.is-open{
  display:block;
  position:fixed;
  inset:0;
  z-index:60;
  overflow:hidden;
}
.modal__backdrop{position:fixed; inset:0; background:rgba(0,0,0,.55); backdrop-filter:blur(6px); z-index:50}
.modal__panel{
  position:fixed;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  width:min(980px, calc(100vw - 24px));

  /* ✅ use modern dynamic viewport units (better on phones) */
  max-height:calc(100dvh - 24px);

  display:flex;               /* ✅ critical */
  flex-direction:column;      /* ✅ critical */

  overflow:hidden;
  z-index:60;
  background:linear-gradient(180deg, #ffffff, #f8fafc);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}
.modal__header{display:flex; justify-content:space-between; align-items:flex-start; gap:12px; padding:16px 16px 12px; border-bottom:1px solid var(--border)}
.modal__title{font-weight:800; font-size:18px}
.modal__sub{color:var(--muted2); font-size:13px; margin-top:4px}
.modal__body{
  padding:14px 16px;

  flex:1 1 auto;                  /* ✅ takes remaining height */
  overflow-y:auto;                 /* ✅ scroll vertically */
  -webkit-overflow-scrolling:touch;/* ✅ iOS momentum scroll */

  overscroll-behavior:contain;     /* ✅ prevents “scroll chaining” */
  touch-action:pan-y;              /* ✅ ensures finger scroll goes here */
}
.modal__footer{display:flex; align-items:center; gap:10px; padding:12px 16px 16px; border-top:1px solid var(--border)}
.icon-btn{
  border:1px solid var(--border);
  background:#ffffff;
  color:var(--text);
  width:38px;
  height:38px;
  border-radius:12px;
  cursor:pointer;
}
.icon-btn:hover{
  border-color:color-mix(in srgb, var(--primary) 45%, var(--border));
  background:color-mix(in srgb, var(--primary) 8%, white);
}
/* =========================================================
   TABLE SYSTEMS (2 TYPES)
   1) Grid-based table (modal editor) → .table + .table__head + .table__row
   2) Real HTML table <table> → .real-table
   ========================================================= */
@media (max-width: 640px){
  .real-table thead{
    display:none;
  }

  .real-table,
  .real-table tbody,
  .real-table tr,
  .real-table td{
    display:block;
    width:100%;
  }

  .real-table tr{
    border:1px solid var(--border);
    border-radius:14px;
    padding:10px 12px;
    margin-bottom:10px;
    background:#fff;
  }

  .real-table td{
    padding:8px 0;
    border:none;
    text-align:left !important;
  }

  .real-table td::before{
    content: attr(data-label);
    display:block;
    font-size:12px;
    color: var(--muted);
    margin-bottom:3px;
  }

  /* stop long titles exploding layout */
  .td-title{
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
}

/* =========================
   1) GRID "TABLE" (MODAL UI)
   ========================= */

/* The grid "table" wrapper */
.table {
  display: grid;
  gap: 10px;
  width: 100%;
}

/* Header row (grid columns match rows) */
.table__head {
  display: grid;
  grid-template-columns: 2fr 140px 70px; /* default (name, date, remove) */
  gap: 10px;
  align-items: center;

  color: var(--muted2, rgba(15, 23, 42, 0.55));
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 0 4px;
}

/* Data row card */
.table__row {
  display: grid;
  grid-template-columns: 2fr 140px 70px; /* default */
  gap: 10px;
  align-items: center;

  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 14px;
  background: #ffffff;
  padding: 12px;

  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.table__row:hover {
  border-color: rgba(15, 23, 42, 0.16);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

/* Grid table can be customized per-instance by inline style:
   style="grid-template-columns:1fr 220px 70px"
   so keep these default values safe */



/* =========================
   FORM FIELDS (USED IN MODAL)
   ========================= */

.field {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: #ffffff;
  color: var(--text, #0f172a);
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
  font: inherit;

  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.field:focus {
  border-color: rgba(79, 70, 229, 0.55);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}

.field::placeholder {
  color: rgba(15, 23, 42, 0.35);
}

.small-note {
  font-size: 12px;
  color: var(--muted2, rgba(15, 23, 42, 0.55));
  margin-top: 6px;
}

.label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.70);
  margin-bottom: 6px;
  letter-spacing: .02em;
}



/* =========================
   2) REAL HTML <table> LOOK
   Use: <table class="real-table">
   ========================= */

.table-wrap{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}

/* Base */
.real-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;

  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 14px;
  overflow: hidden;

  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  min-width:720px;
}

/* Header */
.real-table thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted2, rgba(15, 23, 42, 0.55));
  text-transform: uppercase;
  letter-spacing: 0.12em;

  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.03);
  border-bottom: 1px solid rgba(15, 23, 42, 0.10);

  /* Optional sticky header; remove if you dislike it */
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Body cells */
.real-table tbody td {
  padding: 14px 16px;
  vertical-align: middle;
  color: var(--text, #0f172a);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  font-size: 14px;
}

/* Last row cleanup */
.real-table tbody tr:last-child td {
  border-bottom: none;
}

/* Row hover */
.real-table tbody tr {
  transition: background 120ms ease;
}

.real-table tbody tr:hover {
  background: rgba(79, 70, 229, 0.035);
}

/* Zebra option (optional – enable if you want) */
.real-table.is-zebra tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.015);
}

/* Numeric columns */
.real-table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Subtext inside a cell */
.real-table .subtext {
  display: block;
  font-size: 12px;
  color: var(--muted2, rgba(15, 23, 42, 0.55));
  margin-top: 4px;
}

/* Tight variant (optional) */
.real-table.is-compact thead th,
.real-table.is-compact tbody td {
  padding: 10px 12px;
  font-size: 13px;
}



/* =========================
   Buttons + Icons (table-friendly)
   ========================= */

.icon-btn {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #ffffff;
  color: var(--text, #0f172a);
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  line-height: 1;

  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.icon-btn:hover {
  border-color: rgba(15, 23, 42, 0.20);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(0px);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

/* Simple badges that look good in either table */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;

  background: rgba(15, 23, 42, 0.06);
  color: rgba(15, 23, 42, 0.75);
}

.badge--warn {
  background: rgba(245, 158, 11, 0.16);
  color: rgba(161, 98, 7, 0.95);
}

.badge--ok {
  background: rgba(34, 197, 94, 0.16);
  color: rgba(21, 128, 61, 0.95);
}

.badge--err {
  background: rgba(239, 68, 68, 0.14);
  color: rgba(153, 27, 27, 0.95);
}



/* =========================
   Responsive improvements
   ========================= */

@media (max-width: 720px) {
  /* Grid table stacks nicer */
  .table__head {
    display: none;
  }

  .table__row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Real tables should scroll on small screens */
  .table-wrap .real-table {
    min-width: 680px;
  }
}
.field:focus{
  box-shadow:0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
  border-color:color-mix(in srgb, var(--primary) 55%, #cbd5e1);
}
.small-note{color:var(--muted2); font-size:12px; margin-top:6px}
@media(max-width:760px){.table__head{display:none}.table__row{grid-template-columns:1fr}}

/* Custom category form */
.custom-category-form{
  border:1px dashed #cbd5e1;
  border-radius:var(--radius2);
  padding:12px;
  margin-top:10px;
  background:#ffffff;
}

.custom-category-form .field{
  width:100%;
}

.custom-categories{
  display:grid;
  gap:16px;
  margin-top:14px;
}


/* Uploaded file list (server-rendered + refreshed via API) */
.uploaded-list{
  margin-top:14px;
  padding-top:12px;
  border-top:1px solid var(--border);
}
.uploaded-list__title{
  font-weight:750;
  margin-bottom:10px;
}
.uploaded-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:14px;
  background:#ffffff;
  margin-top:10px;
}
.uploaded-item__name{ font-weight:650; }
.uploaded-item__sub{ margin-top:2px; }
.uploaded-item__actions{display:flex; align-items:center; gap:10px; flex-wrap:wrap}
.badge--warn{
  border-color:rgba(245,158,11,.35);
  background:rgba(245,158,11,.12);
  color:#92400e;
}
/* ===========================
   AUTH / LOGIN PAGE
   =========================== */

.auth-shell{
  display:grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap:24px;
  align-items:start;
  max-width: 980px;
  margin: 28px auto;
  padding: 0 16px;
}

@media (max-width: 900px){
  .auth-shell{
    grid-template-columns: 1fr;
  }
  .auth-aside{
    order:-1;
  }
}

.auth-card{
  border:1px solid var(--border);
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 10px 26px rgba(2, 6, 23, 0.06);
}

.auth-brand{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom: 14px;
}

.auth-logo{
  width:44px;
  height:44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary, #4F46E5), var(--accent, #06B6D4));
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
  letter-spacing: .02em;
}

.auth-appname{
  font-weight: 800;
  font-size: 16px;
  line-height: 1.1;
}

.auth-byline{
  font-size: 12px;
  color: var(--muted2);
  margin-top: 2px;
}

.auth-title{
  margin: 4px 0 6px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.auth-subtitle{
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form{
  display:flex;
  flex-direction:column;
  gap: 14px;
}

.field-group{
  display:flex;
  flex-direction:column;
  gap: 6px;
}

.field-wrap{
  position: relative;
}

.field-wrap .field{
  padding-right: 44px;
}

.field-wrap .icon-btn{
  position:absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(248, 250, 252, 0.8);
  cursor:pointer;
}

.auth-toggle{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 2px;
}

.toggle-btn{
  border: 1px solid var(--border);
  background: #fff;
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 650;
  color: var(--text);
}

.toggle-btn.is-active{
  border-color: rgba(79, 70, 229, 0.35);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.12);
  background: rgba(79, 70, 229, 0.06);
}

.auth-panel{
  display:flex;
  flex-direction:column;
  gap: 12px;
}

.code-actions{
  border: 1px dashed rgba(15, 23, 42, 0.15);
  border-radius: 16px;
  padding: 12px;
  background: rgba(248,250,252,0.6);
}

.auth-links{
  display:flex;
  justify-content:flex-end;
}

.link-muted{
  color: var(--muted2);
  text-decoration: none;
  font-size: 13px;
}
.link-muted:hover{
  color: var(--text);
  text-decoration: underline;
}

.auth-footer{
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.auth-footer__row{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill{
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  font-weight:650;
  border:1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  background:color-mix(in srgb, var(--primary) 10%, white);
  color:var(--text);
}

.pill--open{
  background:rgba(234,179,8,.10);   /* yellow-ish */
  border-color:rgba(234,179,8,.35);
}

.pill--closed{
  background:rgba(34,197,94,.10);   /* green-ish */
  border-color:rgba(34,197,94,.35);
}

/* Side panel */
.auth-aside__card{
  border:1px solid var(--border);
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 10px 26px rgba(2, 6, 23, 0.04);
}

.auth-points{
  display:flex;
  flex-direction:column;
  gap: 14px;
  margin-top: 14px;
}

.auth-point{
  display:flex;
  gap: 12px;
  align-items:flex-start;
}

.auth-point__icon{
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(6, 182, 212, 0.12);
}

.auth-point__title{
  font-weight: 750;
  margin-bottom: 2px;
}

.auth-point__desc{
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

.auth-aside__footer{
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.banner{
  margin: 12px 0 18px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.35;
  border: 1px solid transparent;
}

.banner--warn{
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.35);
  color: #92400e;
  font-weight: 600;
}

/* =========================
   Helper tooltip icon + bubble
   ========================= */

/* The small "?" icon */
.helper-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 18px;
  height: 18px;
  border-radius: 999px;

  border: 1px solid rgba(0, 0, 0, 0.25);
  background: #fff;

  font-size: 12px;
  font-weight: 700;
  line-height: 1;

  cursor: help;
  user-select: none;
  flex: 0 0 auto;

  transition: transform 120ms ease, box-shadow 120ms ease;
}

.helper-icon:hover,
.helper-icon:focus {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  outline: none;
}

/* Tooltip bubble text (uses aria-label for content) */
.helper-icon::after {
  content: attr(aria-label);

  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  transform: translateX(-50%) translateY(-2px);

  min-width: 240px;
  max-width: 360px;

  padding: 10px 12px;
  border-radius: 10px;

  background: rgba(15, 23, 42, 0.96); /* slate */
  color: #fff;

  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.1px;

  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  z-index: 50;

  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

/* Tooltip arrow */
.helper-icon::before {
  content: "";

  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);

  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 7px solid rgba(15, 23, 42, 0.96);

  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

/* Show tooltip on hover/focus */
.helper-icon:hover::after,
.helper-icon:focus::after,
.helper-icon:hover::before,
.helper-icon:focus::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Reduce tooltip width on small screens */
@media (max-width: 520px) {
  .helper-icon::after {
    min-width: 200px;
    max-width: 260px;
  }
}

.doc-section__head {
  position: relative;
  overflow: visible !important;
  z-index: 5;
}

.helper-icon {
  position: relative;
  z-index: 9999;
}

.helper-icon::before,
.helper-icon::after {
  z-index: 10000;
}
.kebab-btn{
  width:36px;
  height:36px;
  border-radius:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:18px;
  line-height:1;
}

.kebab-menu{
  position:absolute;
  right:0;
  top:44px;
  min-width:220px;
  background:#fff;
  border:1px solid rgba(0,0,0,0.08);
  border-radius:14px;
  box-shadow:0 12px 30px rgba(0,0,0,0.12);
  padding:8px;
  z-index:50;
}

.kebab-item{
  display:block;
  width:100%;
  text-align:left;
  padding:10px 12px;
  border-radius:10px;
  background:transparent;
  border:0;
  color:inherit;
  cursor:pointer;
  font:inherit;
}

.kebab-item:hover{
  background:#f3f4f6;
}

a.kebab-item {
  text-decoration: none;
  color: inherit;
  display: block;
}
a.kebab-item:hover {
  text-decoration: none;
}

/* Force Tom Select control to match your input height */
.ts-wrapper .ts-control {
  height: 20px;
  min-height: 20px;
  padding: 0 10px;              /* adjust horizontal padding */
  display: flex;
  align-items: center;          /* vertically center text */
  box-sizing: border-box;
}

/* Make the internal text input also align nicely */
.ts-wrapper .ts-control input {
  line-height: 20px;            /* ~30px minus borders */
  height: 20px;
}

/* If you use single-select, keep the text vertically centered */
.ts-wrapper.single .ts-control .item {
  line-height: 20px;
}

/* ============================================================
   TomSelect - Taller style ONLY inside the metadata modal
   ============================================================ */

#metaModal .ts-wrapper .ts-control {
  height: 38px;
  min-height: 38px;
  padding: 0 12px;            /* horizontal padding */
  display: flex;
  align-items: center;        /* vertical centering */
  box-sizing: border-box;
}

/* Make the internal text input align nicely */
#metaModal .ts-wrapper .ts-control input {
  line-height: 38px;
  height: 38px;
}

/* Single-select item vertical centering */
#metaModal .ts-wrapper.single .ts-control .item {
  line-height: 38px;
}

/* Optional: dropdown arrow spacing doesn't feel cramped */
#metaModal .ts-wrapper.single .ts-control:after {
  top: 50%;
  transform: translateY(-50%);
}

@media (max-width: 520px) {
  #metaModal .ts-wrapper .ts-control {
    height: 44px;
    min-height: 44px;
  }
  #metaModal .ts-wrapper .ts-control input {
    line-height: 44px;
    height: 44px;
  }
  #metaModal .ts-wrapper.single .ts-control .item {
    line-height: 44px;
  }
}

/* ============================================================
   TomSelect - nice sizing for Edit Matter modal
   ============================================================ */

#editMatterModal .ts-wrapper{
  width:100%;
}

#editMatterModal .ts-control{
  width:100%;
  min-height:44px;                 /* matches your inputs */
  padding:6px 10px;                /* not huge */
  border-radius:12px;
  border:1px solid rgba(15,23,42,0.14);
  background:#fff;
  box-shadow:none;
  display:flex;
  align-items:center;
  gap:6px;
}

#editMatterModal .ts-control input{
  font: inherit;
  line-height: 1.2;
}

/* focus ring consistent with .field */
#editMatterModal .ts-wrapper:focus-within .ts-control{
  border-color: rgba(79, 70, 229, 0.55);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}

/* Multi-select "chips" look clean */
#editMatterModal .ts-wrapper.multi .ts-control > .item{
  background: color-mix(in srgb, var(--primary) 10%, white);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: 999px;
  padding: 4px 8px;
  margin: 2px 4px 2px 0;
  font-size: 13px;
  font-weight: 650;
}

/* dropdown */
#editMatterModal .ts-dropdown{
  border-radius:12px;
  border:1px solid rgba(15,23,42,0.12);
  overflow:hidden;
}

#editMatterModal .ts-dropdown .option{
  padding:10px 12px;
}

.req__left{
  display:flex;
  align-items:flex-start;
  gap:10px;
}

.req__status{
  width:18px;
  height:18px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:12px;
  font-weight:700;
  flex:0 0 auto;
  margin-top:2px;
}

.req__status--ok{
  background: rgba(34,197,94,0.15);
  color: #16a34a;
  border: 1px solid rgba(34,197,94,0.4);
}

.req__status--warn{
  background: rgba(245,158,11,0.15);
  color: #b45309;
  border: 1px solid rgba(245,158,11,0.4);
}

.field--link{
  display:flex;
  align-items:center;
  height:30px;           /* match your desired control height */
  line-height:30px;
  text-decoration:none;
  cursor:pointer;

  /* prevent overflow on mobile */
  min-width:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

@keyframes metaBannerFlicker {
  0%   { opacity: 1;   transform: translateX(0); }
  15%  { opacity: .25; transform: translateX(-2px); }
  30%  { opacity: 1;   transform: translateX(2px); }
  45%  { opacity: .25; transform: translateX(-2px); }
  60%  { opacity: 1;   transform: translateX(2px); }
  100% { opacity: 1;   transform: translateX(0); }
}

#metaRequiredBanner.is-flicker {
  animation: metaBannerFlicker 550ms ease-in-out;
}

input[type="date"]{
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  box-sizing: border-box;

  -webkit-appearance: none;
  appearance: none;
}

.meta-grid{
  display:grid;
  grid-template-columns: 1.4fr 1fr 140px;
  gap:14px;
  align-items:start;
}

.meta-download{
  display:flex;
  flex-direction:column;
  gap:2px;
  text-decoration:none;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid rgba(0,0,0,0.12);
  background:#fff;
}

.meta-download:hover{
  border-color: rgba(0,0,0,0.25);
}

.meta-download__title{
  font-weight:700;
}

.meta-download__sub{
  font-size:12px;
  color:rgba(0,0,0,0.55);
}

.meta-filename{
  margin-top:8px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.meta-actions{
  display:flex;
  flex-direction:column;
}

@media (max-width: 720px){
  .meta-grid{
    grid-template-columns: 1fr;
  }

  .meta-actions button{
    width:100%;
  }
}

.meta-panel{
  padding:14px 16px 0;
}

.meta-panel__head{
  margin-bottom:10px;
}

.meta-panel__title{
  font-weight:800;
  font-size:14px;
}

.meta-panel__sub{
  margin-top:3px;
}

.meta-form-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:12px;
  margin: 12px 0;
}

.meta-field{
  background:rgba(0,0,0,0.03);
  border:1px solid rgba(0,0,0,0.08);
  border-radius:12px;
  padding:12px;
}

.meta-field--full{
  grid-column:1 / -1;
}

.meta-label{
  display:block;
  font-size:12px;
  font-weight:700;
  letter-spacing:0.02em;
  text-transform:uppercase;
  color:rgba(0,0,0,0.6);
  margin-bottom:8px;
}

.meta-help{
  margin-top:6px;
}

.meta-other{
  margin-top:12px;
  padding-top:12px;
  border-top:1px dashed rgba(0,0,0,0.15);
}

@media (max-width: 720px){
  .meta-form-grid{
    grid-template-columns:1fr;
  }
}

/* ============================================================
   metaTable injected HTML (meta-grid) - stop right overflow
   ============================================================ */

#metaModal #metaTable{
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

#metaModal #metaTable .meta-grid{
  width: 100%;
  max-width: 100%;
  min-width: 0;

  /* ✅ critical: allows columns to shrink without forcing overflow */
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 140px;
}

/* ✅ critical: allow grid children to shrink */
#metaModal #metaTable .meta-grid > *{
  min-width: 0;
}

/* ✅ critical: document “download” block must be shrinkable (it’s flex) */
#metaModal #metaTable .meta-download{
  min-width: 0;
  max-width: 100%;
}

/* ✅ critical: clamp long filenames */
#metaModal #metaTable .meta-filename{
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Optional: if you want wrapping instead of ellipsis, swap to this:
#metaModal #metaTable .meta-filename{
  white-space: normal;
  overflow-wrap: anywhere;
}
*/

/* ✅ Mobile stacking stays clean */
@media (max-width: 720px){
  #metaModal #metaTable .meta-grid{
    grid-template-columns: 1fr;
  }

  #metaModal #metaTable .meta-actions button{
    width: 100%;
  }
}