:root{
  /* Brand */
  --primary:#4C1D95;
  --accent:#7C3AED;

  /* Light UI */
  --bg:#F7F2FF;
  --text:#1F1140;
  --muted:#5B4C82;
  --muted2:#7A68A7;

  --border:#E7DDF7;
  --shadow:0 18px 45px rgba(76,29,149,.14);

  --radius:18px; --radius2:14px; --max:1100px;
  --font-ui: "Inter", "Segoe UI Variable", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Inter", "Segoe UI Variable", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font: var(--font-ui);
}

html.no-scroll,
body.no-scroll{
  overflow: hidden !important;
}
*{box-sizing:border-box}
body{
  margin:0; font-family:var(--font); color:var(--text);
  line-height:1.45;
  text-rendering:optimizeLegibility;
  -webkit-font-smoothing:antialiased;
  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%;
}
h1, h2, h3, h4, h5, h6,
.h1, .h2,
.brand__name,
.doc-section__title,
.modal__title,
.table__head,
.real-table thead th{
  font-family:var(--font-display);
  letter-spacing:.005em;
}
button, input, select, textarea{
  font-family:var(--font-ui);
}
.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(247,242,255,.84);
  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, #1D4ED8, #06B6D4);
  border:1px solid rgba(29,78,216,.45);
  box-shadow:0 12px 28px rgba(29,78,216,.22);

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

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

.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__shortcut{
  margin-left:auto;
}
.btn--shortcut{
  padding:6px 10px;
  font-size:12px;
  border-radius:999px;
  white-space:nowrap;
}

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

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

.doc-section__coverage{
  margin-top:6px;
  font-size:12px;
  line-height:1.45;
  color:#334155;
  background:#f1f5f9;
  border:1px solid #cbd5e1;
  border-radius:10px;
  padding:6px 8px;
}

.doc-section__coverage strong{
  color:#0f172a;
  font-weight:700;
}

/* 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; font-weight:650;}
.h2{margin:0 0 12px; font-size:16px; font-weight:620;}
.pill-row{display:flex; flex-wrap:wrap; gap:10px; margin-top:12px}
#metaModal .pill-row{
  justify-content: center;
  align-items: center;
}
#metaModal .pill-row .spacer{
  display: none;
}
.pill{
  font-size:13px; padding:8px 10px; border-radius:999px;
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--primary) 6%, white);
}
.pill--select{
  cursor:pointer;
  background:#ffffff;
  margin:0;
  line-height:1;
}
.pill--select.is-active{
  border-color:color-mix(in srgb, var(--primary) 70%, #000000);
  background:color-mix(in srgb, var(--primary) 18%, white);
}
.no-results{
  padding:10px 12px;
  display:flex;
  flex-direction:column;
  gap:8px;
  color:var(--muted);
  font-size:13px;
}
.ts-other-btn{
  align-self:flex-start;
  border:1px solid var(--border);
  background:#ffffff;
  color:var(--text);
  padding:6px 10px;
  border-radius:999px;
  font-weight:700;
  cursor:pointer;
}
.ts-other-btn:hover{
  border-color:color-mix(in srgb, var(--primary) 55%, var(--border));
  background:color-mix(in srgb, var(--primary) 8%, 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}

.req__coverage{
  margin-top:6px;
  font-size:12px;
  line-height:1.45;
  color:#334155;
  background:#f1f5f9;
  border:1px solid #cbd5e1;
  border-radius:10px;
  padding:6px 8px;
}

.req__coverage strong{
  color:#0f172a;
  font-weight:700;
}
.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}
.matter-summary{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap:12px;
  margin-top:12px;
}
.matter-summary__item{
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px 14px;
  background:linear-gradient(180deg, #ffffff, #f8fafc);
}
.matter-summary__label{
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.08em;
  color:var(--muted2);
}
.matter-summary__value{
  margin-top:6px;
  font-size:20px;
  font-weight:600;
  color:var(--text);
}
.matter-summary__meta{
  margin-top:6px;
  font-size:12px;
  color:var(--muted2);
}
.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:600;
  letter-spacing:.005em;
  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);
}
.upload-toast{
  position:fixed;
  left:50%;
  right:auto;
  top:50%;
  transform:translate(-50%, -50%);
  opacity:0;
  pointer-events:none;
  z-index:9998;
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 14px;
  width:min(92vw, 420px);
  justify-content:center;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.96);
  box-shadow:0 14px 30px rgba(15,23,42,.18);
  color:#0f172a;
  font-size:13px;
  font-weight:600;
  transition:opacity .2s ease, transform .2s ease;
}
.upload-toast.upload-toast--modal{
  position:fixed;
  left:50%;
  right:auto;
  top:50%;
  bottom:auto;
  transform:translate(-50%, -50%);
  z-index:10010;
}
.upload-toast.is-interactive{
  pointer-events:auto;
  cursor:pointer;
}
.upload-toast.is-closable{
  pointer-events:auto;
  cursor:default;
}
.upload-toast.is-interactive:not(.is-button-actions):hover{
  background:linear-gradient(135deg, #fff7e8 0%, #ffefcf 100%);
  border-color:#e9bf73;
  box-shadow:0 18px 36px rgba(74,42,0,.20);
}
.upload-toast.is-interactive:not(.is-button-actions):hover:has(.upload-toast__close:hover){
  background:rgba(255,255,255,.96);
  border-color:var(--border);
  box-shadow:0 14px 30px rgba(15,23,42,.18);
}
.upload-toast.is-button-actions{
  cursor:default;
}
.upload-toast__icon{
  width:22px;
  height:22px;
  border-radius:999px;
  display:grid;
  place-items:center;
  background:rgba(34,197,94,.15);
  color:#166534;
  font-weight:800;
  font-size:14px;
}
.upload-toast__actions{
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.upload-toast__action{
  border:none;
  background:transparent;
  color:#0f172a;
  font-weight:700;
  cursor:pointer;
  padding:4px 8px;
  border-radius:999px;
}
.upload-toast__action:hover{
  background:rgba(15,23,42,.08);
}
.upload-toast__close{
  position: absolute;
  right: -10px;
  top: -10px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border:none;
  background:transparent;
  color:#0f172a;
  font-weight:700;
  cursor:pointer;
  padding:0;
  border-radius:999px;
  line-height:1;
  background:#fff;
  box-shadow:0 6px 18px rgba(15,23,42,.18);
}
.upload-toast__close:hover{
  background:rgba(15,23,42,.08);
}
.upload-toast.is-show{
  opacity:1;
  transform:translate(-50%, -50%);
}

.upload-toast.is-pulse{
  animation:toastPulse .68s cubic-bezier(.22,.61,.36,1);
}

@keyframes toastPulse{
  0%{
    transform:translate(-50%, -50%) scale(1);
    box-shadow:0 14px 30px rgba(15,23,42,.18);
  }
  35%{
    transform:translate(-50%, -50%) scale(1.075);
    box-shadow:0 22px 42px rgba(29,78,216,.30);
  }
  65%{
    transform:translate(-50%, -50%) scale(.985);
    box-shadow:0 10px 24px rgba(15,23,42,.16);
  }
  100%{
    transform:translate(-50%, -50%) scale(1);
    box-shadow:0 14px 30px rgba(15,23,42,.18);
  }
}

.modal--locked .modal__panel{
  pointer-events:none;
}
.upload-inline-toast{
  position:absolute;
  left:50%;
  top:14px;
  transform:translateX(-50%) translateY(-6px);
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 14px;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(240,253,244,.98);
  box-shadow:0 16px 36px rgba(15,23,42,.2);
  color:#0f172a;
  font-size:13px;
  font-weight:800;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease, transform .2s ease;
  max-width:calc(100% - 32px);
  text-align:center;
  white-space:normal;
  z-index:5;
}
.upload-inline-toast::before{
  content:"✓";
  display:inline-grid;
  place-items:center;
  width:20px;
  height:20px;
  border-radius:999px;
  background:rgba(34,197,94,.18);
  color:#166534;
  font-weight:800;
  font-size:12px;
}
.upload-inline-toast.is-show{
  opacity:1;
  transform:translateX(-50%) translateY(0);
}
@media(max-width:600px){
  .upload-inline-toast{
    position:fixed;
    top:120px;
    left:50%;
    transform:translateX(-50%) translateY(-6px);
    padding:8px 12px;
    font-size:12px;
    z-index:3000;
  }
}
@media(max-width:700px){
  .upload-toast{
    top:50%;
    bottom:auto;
    transform:translate(-50%, -50%);
  }
  .upload-toast.is-show{
    transform:translate(-50%, -50%);
  }
  .upload-toast.upload-toast--modal{
    top:50%;
  }
}
.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;
}

/* Warn / Attention */
.notice--warn{
  border-color: rgba(245,158,11,.45);
  background: rgba(245,158,11,.12);
  color: #92400e;
}

.prediction-control{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:nowrap;
  min-width:0;
  margin-top:10px;
  margin-bottom:6px;
}
.prediction-control__value{
  flex:1 1 auto;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.prediction-control__actions{
  display:inline-flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
  white-space:nowrap;
}
.prediction-control [data-prediction-accept],
.prediction-control [data-prediction-reject]{
  border-radius:999px;
  border:1px solid transparent;
  padding:4px 10px;
  font-size:12px;
  font-weight:600;
  cursor:pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.prediction-control [data-prediction-accept]{
  background:rgba(34,197,94,.14);
  color:#166534;
  border-color:rgba(34,197,94,.35);
}
.prediction-control [data-prediction-accept]:hover{
  background:rgba(34,197,94,.2);
}
.prediction-control [data-prediction-reject]{
  background:rgba(245,158,11,.18);
  color:#92400e;
  border-color:rgba(245,158,11,.4);
}
.prediction-control [data-prediction-reject]:hover{
  background:rgba(245,158,11,.26);
}
.prediction-control--miss .prediction-control__miss{
  background:rgba(100,116,139,.14);
  color:#475569;
  border:1px solid rgba(100,116,139,.35);
  border-radius:999px;
  padding:4px 10px;
  font-size:12px;
  font-weight:600;
  margin-left:auto;
  white-space:nowrap;
}

#metaModal .meta-field .prediction-control{
  margin-top:10px;
  margin-bottom:8px;
}

.meta-banner{
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  max-width: 860px;
  width: calc(100% - 24px);
  background: linear-gradient(135deg, #fff8e8 0%, #ffefc8 52%, #ffe7b2 100%);
  border: 1px solid #f2c66a;
  color: #4a2a00;
  box-shadow: 0 16px 38px rgba(74, 42, 0, 0.22);
}

.meta-field.prediction-miss{
  position: relative;
}
.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__panel--with-banner{
  max-height:calc(100dvh - 80px);
  height:calc(100dvh - 120px);
  top: 12%;
  transform: translate(-50%, 0);
}
.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__header-actions{display:flex; align-items:center; gap:8px}
.modal-preview-btn{
  width:42px;
  height:42px;
  border-radius:12px;
  font-size:18px;
  line-height:1;
}
.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;
}

/* ============================================================
   New matter layout
   ============================================================ */

.new-matter__head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
}
.new-matter__form{
  margin-top:14px;
}
.new-matter__section{
  padding:14px 0;
  border-top:1px solid rgba(15,23,42,0.08);
}
.new-matter__section:first-of-type{
  border-top:0;
  padding-top:0;
}
.new-matter__sectionTitle{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
  color: rgba(15,23,42,0.55);
  margin-bottom:8px;
}
.new-matter__actions{
  margin-top:16px;
}



/* =========================
   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%;
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;

  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: 0;
}

/* 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;
  overflow-wrap: anywhere;
}

/* 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;
  overflow-wrap: anywhere;
}

/* 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;
}

/* Banner notices can break table cell layout; keep notices compact inside tables. */
.real-table td .notice {
  margin-top: 0;
}

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

/* Shared action-column helpers for real tables */
.real-table__actions-head {
  width: 140px;
  text-align: center !important;
  white-space: nowrap;
}

.real-table__actions-cell {
  white-space: nowrap;
}

.real-table__actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.real-table__actions--end {
  justify-content: flex-end;
}

.real-table__actions .btn {
  min-width: 88px;
}

.requested-docs-table {
  table-layout: auto;
}

.requested-docs-table__category-head,
.requested-docs-table__category-cell {
  min-width: 160px;
}

.requested-docs-table__type-head,
.requested-docs-table__type-cell {
  min-width: 220px;
}

.requested-docs-table__actions-head {
  width: 180px;
}

.requested-docs-table__actions-cell {
  min-width: 180px;
}

.requested-docs-table .field[type="date"] {
  min-width: 140px;
}

.requested-docs-table__category-cell,
.requested-docs-table__type-cell {
  overflow-wrap: anywhere;
}

.requested-docs-table .real-table__actions .btn {
  min-width: 0;
}

.matter-audit-table {
  table-layout: auto;
}

.matter-audit-table__outcome-head {
  width: 110px;
  white-space: nowrap;
}

.audit-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  font-weight: 700;
}

.audit-pill--success {
  border-color: rgba(34, 197, 94, .35);
  background: rgba(34, 197, 94, .12);
  color: #166534;
}

.audit-pill--fail {
  border-color: rgba(239, 68, 68, .35);
  background: rgba(239, 68, 68, .12);
  color: #991b1b;
}

.audit-pill--warn {
  border-color: rgba(245, 158, 11, .45);
  background: rgba(245, 158, 11, .14);
  color: #92400e;
}

/* Matters table keeps the actions column stable and avoids button collapse */
.matters-table {
  table-layout: auto;
}

.matters-table__actions-head {
  width: 128px;
  text-align: center !important;
  white-space: nowrap;
}

.matters-table__actions-cell {
  white-space: nowrap;
}

.matters-table__actions {
  display: flex;
  justify-content: center;
  align-items: center;
}

.matters-table__actions .btn {
  min-width: 92px;
}



/* =========================
   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;
  }

  .real-table__actions,
  .matters-table__actions {
    justify-content: flex-start;
  }
}
.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:650;
  margin-bottom:10px;
}
.uploaded-item{
  display:grid;
  grid-template-columns:minmax(0, 1fr) auto;
  grid-template-rows:auto auto;
  align-items:center;
  gap:12px;
  min-width:0;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:14px;
  background:#ffffff;
  margin-top:10px;
}
.uploaded-item--draft{
  background:linear-gradient(180deg, #f8fbff 0%, #f2f8ff 100%);
  border-color:rgba(59,130,246,.28);
}
.uploaded-item__meta{
  flex:1 1 auto;
  min-width:0;
  padding-right:6px;
}
.uploaded-item__name{
  font-weight:560;
  min-width:0;
  overflow-wrap:anywhere;
  word-break:break-word;
}
.uploaded-item__sub{ margin-top:2px; }
.uploaded-item > .uploaded-item__sub{
  grid-column:1 / -1;
  margin-top:0;
  width:100%;
}
.uploaded-item__status{
  margin-top:6px;
}
.notice__row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.notice__btn{
  padding:6px 10px;
  font-size:12px;
}
.uploaded-item__actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:nowrap;
  justify-content:flex-end;
  flex:0 0 auto;
  min-width:0;
  align-self:start;
}
.uploaded-item__actions .btn{
  white-space:nowrap;
  flex:0 0 auto;
}
.uploaded-item__actions .uploaded-action-btn{
  width:38px;
  height:38px;
  min-width:38px;
  min-height:38px;
  padding:0;
  border-radius:11px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:17px;
  line-height:1;
  font-weight:700;
  text-decoration:none;
  color:var(--text);
  border:1px solid rgba(15,23,42,.18);
  background:#ffffff;
}
.uploaded-item__actions .uploaded-action-btn:hover{
  transform:translateY(-1px);
  box-shadow:0 8px 18px rgba(15,23,42,.14);
}
.uploaded-item__actions .uploaded-action-btn--download{
  color:#0f4d9b;
  border-color:rgba(29,78,216,.34);
  background:rgba(29,78,216,.08);
}
.uploaded-item__actions .uploaded-action-btn--download:hover{
  border-color:rgba(29,78,216,.5);
  background:rgba(29,78,216,.12);
}
.uploaded-item__actions .uploaded-action-btn--edit{
  color:#1e3a8a;
  border-color:rgba(30,58,138,.34);
  background:rgba(59,130,246,.12);
}
.uploaded-item__actions .uploaded-action-btn--edit:hover{
  border-color:rgba(30,58,138,.5);
  background:rgba(59,130,246,.18);
}
.uploaded-item__actions .uploaded-action-btn--continue{
  color:#1e3a8a;
  border-color:rgba(30,58,138,.34);
  background:rgba(59,130,246,.12);
}
.uploaded-item__actions .uploaded-action-btn--continue:hover{
  border-color:rgba(30,58,138,.5);
  background:rgba(59,130,246,.18);
}
.uploaded-item__actions .uploaded-action-btn--delete{
  color:#991b1b;
  border-color:rgba(239,68,68,.42);
  background:rgba(239,68,68,.14);
}
.uploaded-item__actions .uploaded-action-btn--delete:hover{
  border-color:rgba(239,68,68,.56);
  background:rgba(239,68,68,.2);
}
.uploaded-item--draft .uploaded-item__actions{
  grid-column:2;
}

.meta-doctype-picker{
  position:relative;
  display:inline-flex;
  align-items:center;
}
.meta-doctype-picker .pill--select{
  min-height:32px;
  display:inline-flex;
  align-items:center;
}

.meta-doctype-list{
  position:absolute;
  top:calc(100% + 8px);
  left:0;
  min-width:260px;
  max-width:min(86vw, 420px);
  max-height:260px;
  overflow:auto;
  z-index:10030;
  padding:8px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#ffffff;
  box-shadow:0 16px 36px rgba(15,23,42,.18);
}

.meta-doctype-option{
  width:100%;
  border:1px solid transparent;
  background:transparent;
  color:var(--text);
  padding:8px 10px;
  border-radius:10px;
  text-align:left;
  font-size:13px;
  cursor:pointer;
}

.meta-doctype-option:hover{
  background:color-mix(in srgb, var(--primary) 9%, white);
  border-color:color-mix(in srgb, var(--primary) 30%, var(--border));
}

.meta-doctype-option.is-active{
  background:color-mix(in srgb, var(--primary) 14%, white);
  border-color:color-mix(in srgb, var(--primary) 40%, var(--border));
  font-weight:600;
}
.req-actions{
  display:flex;
  gap:8px;
  justify-content:flex-end;
  align-items:center;
  flex-wrap:wrap;
  white-space:normal;
}
@media (max-width: 640px){
  .req-actions{
    flex-wrap:wrap;
    justify-content:flex-start;
  }
  .req-actions .btn{
    padding:8px 10px;
    font-size:13px;
  }
}

.badge--warn{
  border-color:rgba(245,158,11,.35);
  background:rgba(245,158,11,.12);
  color:#92400e;
}
.badge--draft{
  border-color:rgba(59,130,246,.35);
  background:rgba(59,130,246,.13);
  color:#1d4ed8;
}
.badge--incomplete{
  border-color:rgba(59,130,246,.35);
  background:rgba(59,130,246,.13);
  color:#1d4ed8;
}
.badge--email{
  border-color:rgba(56,189,248,.35);
  background:rgba(56,189,248,.16);
  color:#075985;
}
/* ===========================
   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, #1D4ED8, #06B6D4);
  border:1px solid rgba(29,78,216,.45);
  box-shadow:0 6px 18px rgba(29,78,216,.24);
  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);
}

#metaFileName{
  max-width:min(56vw, 560px);
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

#metaModal #metaFileCounter{
  background:#fff;
  border-color:var(--border);
}

/* 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;
  min-width: 38px;
  flex: 0 0 38px;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 18px;
  line-height: 1;
  background: color-mix(in srgb, var(--accent) 16%, #ffffff);
}

.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{
  height:36px;
  padding:0 14px;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.9);
  color:var(--text);
  font-size:13px;
  font-weight:700;
  letter-spacing:0.02em;
  text-transform:uppercase;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  cursor:pointer;
}
.kebab-btn:hover{
  border-color:color-mix(in srgb, var(--primary) 45%, var(--border));
  background:color-mix(in srgb, var(--primary) 6%, white);
}
.kebab-btn:focus{
  outline:2px solid color-mix(in srgb, var(--primary) 45%, white);
  outline-offset:2px;
}
.kebab{
  position: relative;
}

.kebab-menu{
  display:none;
  position:absolute;
  right:0;
  top:calc(100% + 2px);
  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:hover .kebab-menu,
.kebab:focus-within .kebab-menu{
  display:block;
}

.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;
}

@media (max-width: 760px){
  .kebab-menu{
    right:auto;
    left:0;
    min-width:min(260px, calc(100vw - 24px));
    max-width:calc(100vw - 24px);
  }
}

/* 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;
}

/* Multi-select should wrap and grow (fix mobile chips not visible) */
.ts-wrapper.multi .ts-control{
  height: auto;
  min-height: 44px;
  flex-wrap: wrap;
  align-items: flex-start;
  padding: 6px 10px;
}
.ts-wrapper.multi .ts-control input{
  height: 24px;
  line-height: 24px;
}

/* ============================================================
   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;
}

/* New matter: match field height for TomSelect */
#lawyerName + .ts-wrapper .ts-control{
  min-height: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,0.14);
  background: #fff;
  display:flex;
  align-items:center;
  gap:6px;
  height: 44px;
  max-height: 44px;
  overflow: hidden;
}
#lawyerName + .ts-wrapper.multi .ts-control{
  flex-wrap: wrap;
  align-items: flex-start;
}
#lawyerName + .ts-wrapper .ts-control input{
  font: inherit;
  line-height: 1.2;
}

/* 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;
}

.field--invalid{
  border-color:#dc2626;
  box-shadow:0 0 0 3px rgba(220,38,38,.15);
}

.field.is-disabled,
.field[disabled]{
  opacity:.4;
  pointer-events:none;
  cursor:not-allowed;
  background:#f1f5f9;
  border-style:dashed;
}

.safari-date-fix.is-disabled{
  opacity:.4;
  pointer-events:none;
}

.ts-wrapper.disabled,
.ts-wrapper.disabled .ts-control{
  opacity:.4;
  pointer-events:none;
  cursor:not-allowed;
}

.meta-field--disabled{
  opacity:.45;
  filter: grayscale(1);
}

@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;
  touch-action: manipulation;
}

.meta-grid{
  display:grid;
  grid-template-columns: minmax(0, 1fr);
  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-doc-actions{
  display:flex;
  align-items:center;
  gap:8px;
}

.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;
}

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

.upload-preview{
  width:min(900px, 92vw);
}

.upload-preview__frame{
  width:100%;
  height:65vh;
  border:1px solid rgba(0,0,0,0.12);
  border-radius:10px;
  background:#fff;
}

.upload-preview__message{
  margin:8px 0;
}

.upload-preview__actions{
  margin-top:10px;
}

@media (max-width: 720px){
  .upload-preview__frame{
    height:50vh;
  }
}

.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;
  }

  /* Keep all modal tiles aligned with the doc-date tile on narrow screens */
  #metaModal .modal__body{
    padding-left: 12px;
    padding-right: 12px;
  }

  #metaModal .meta-panel{
    padding-left: 0;
    padding-right: 0;
  }

  #metaModal .meta-form-grid,
  #metaModal .meta-field.meta-field--full,
  #metaModal #metaTable{
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  #metaModal .meta-form-grid > .meta-field,
  #metaModal #metaTable .meta-grid > .meta-field{
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

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

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

/* metaTable sits inside a .meta-field wrapper in upload.html.
   Remove that outer tile styling so the inner doc-date tile matches others. */
#metaModal .meta-panel > .meta-field.meta-field--full{
  background: transparent;
  border: 0;
  padding: 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, 1fr);
}

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

/* Keep doc-date tile visual weight consistent with other meta tiles */
#metaModal input.field[type="date"]{
  background: #fff;
}

/* ✅ 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;
  }

}

.meta-supporting-wrap {
  border: 1px dashed #cbd5e1;
  padding: 12px;
  margin: 12px 0;
  border-radius: 10px;
  background: #f8fafc;
}

.supporting-checkbox {
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
}

.supporting-summary {
  margin-top: 10px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.supporting-summary-text {
  font-size: 0.95rem;
  color: #0f172a;
}

.supporting-hint {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #475569;
}

.supporting-panel {
  max-width: 520px;
}

/* Slightly shorten upload/supporting modals for better viewport fit */
#metaModal .modal__panel--with-banner{
  max-height: calc(95dvh - 80px);
  height: calc(95dvh - 120px);
}

#supportingModal .supporting-panel,
#packSupportingModal .supporting-panel{
  max-height: calc(95dvh - 80px);
  height: auto;
}

.support-switch{
  display:inline-flex;
  align-items:center;
  gap:10px;
  margin-right:10px; /* space before Prev/Next */
  user-select:none;
  cursor:pointer;
  padding:6px 10px;
  border:1px solid rgba(0,0,0,.08);
  border-radius:999px;
  background:#fff;
}

.support-switch__text{
  font-size:13px;
  font-weight:600;
  color:#111827;
  opacity:.9;
  min-width:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* hide native checkbox */
.support-switch input{
  position:absolute;
  opacity:0;
  width:1px;
  height:1px;
}

/* visual toggle */
.support-switch__ui{
  width:42px;
  height:24px;
  border-radius:999px;
  background:#e5e7eb;
  position:relative;
  transition:background .15s ease;
  flex:0 0 auto;
}

.support-switch__ui::after{
  content:"";
  width:20px;
  height:20px;
  border-radius:999px;
  background:#fff;
  position:absolute;
  top:2px;
  left:2px;
  box-shadow:0 1px 2px rgba(0,0,0,.15);
  transition:transform .15s ease;
}

/* checked state */
.support-switch input:checked + .support-switch__ui{
  background:#111827; /* match your brand bar dark */
}
.support-switch input:checked + .support-switch__ui::after{
  transform:translateX(18px);
}

/* keyboard focus */
.support-switch input:focus-visible + .support-switch__ui{
  outline:2px solid rgba(17,24,39,.35);
  outline-offset:2px;
}

.auth-card { position: relative; }

  .auth-overlay{
    position:absolute;
    inset:0;
    display:none;
    align-items:center;
    justify-content:center;
    background: rgba(17,24,39,.55);
    backdrop-filter: blur(2px);
    border-radius: 18px; /* match your card radius */
    z-index: 50;
  }
  .auth-overlay.is-open{ display:flex; }

  .auth-overlay__panel{
    display:flex;
    align-items:center;
    gap:12px;
    padding:14px 16px;
    background: rgba(255,255,255,.96);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0,0,0,.18);
    color:#111827;
  }

  .auth-overlay__spinner{
    width:18px; height:18px;
    border-radius:999px;
    border:2px solid rgba(17,24,39,.2);
    border-top-color: rgba(17,24,39,.85);
    animation: authspin .8s linear infinite;
  }
  @keyframes authspin { to { transform: rotate(360deg); } }

  .auth-overlay__text{
    font-weight:600;
    font-size: 14px;
    white-space: nowrap;
  }

  .upload-overlay{
    position:fixed;
    inset:0;
    border-radius:0;
    z-index:2000;
  }

#requestedDocsTable .row-drag-handle{
  cursor: grab;
  border: 0;
  background: transparent;
  font-size: 16px;
  line-height: 1;
  padding: 6px 6px;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

#requestedDocsTable tr.is-dragging{
  opacity: 0.45;
}

#requestedDocsTable th:first-child,
#requestedDocsTable td:first-child{
  width: 38px;
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
}

.icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:36px;
  height:36px;
  border-radius:10px;
  border:1px solid rgba(0,0,0,.12);
  background:#fff;
  cursor:pointer;
}
.icon-btn:disabled{ opacity:.6; cursor:not-allowed; }

/* Pulse for required banner attention */
@keyframes noticePulse {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(239,68,68,.55); }
  40%  { transform: scale(1.03); box-shadow: 0 0 0 14px rgba(239,68,68,.08); }
  70%  { transform: scale(.995); box-shadow: 0 0 0 8px rgba(239,68,68,0); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

.notice.is-pulse {
  animation: noticePulse 820ms cubic-bezier(.22,.61,.36,1);
}

.meta-banner.notice.is-pulse {
  animation: metaBannerPulse 820ms cubic-bezier(.22,.61,.36,1);
}

@keyframes metaBannerPulse {
  0% {
    transform: translateX(-50%) scale(1);
    box-shadow: 0 16px 38px rgba(74, 42, 0, 0.22);
  }
  40% {
    transform: translateX(-50%) scale(1.03);
    box-shadow: 0 24px 44px rgba(245, 158, 11, 0.34);
  }
  70% {
    transform: translateX(-50%) scale(0.995);
    box-shadow: 0 14px 30px rgba(74, 42, 0, 0.18);
  }
  100% {
    transform: translateX(-50%) scale(1);
    box-shadow: 0 16px 38px rgba(74, 42, 0, 0.22);
  }
}

@keyframes uploadedPulse {
  0%   { transform: scale(1);   box-shadow: 0 0 0 0 rgba(59,130,246,.40); }
  60%  { transform: scale(1.01); box-shadow: 0 0 0 12px rgba(59,130,246,0); }
  100% { transform: scale(1);   box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}

.uploaded-item.is-pulse {
  animation: dnPulse 0.9s ease-out;
}
@keyframes dnPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(59,130,246,.0); }
  30% { transform: scale(1.01); box-shadow: 0 0 0 6px rgba(59,130,246,.25); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}
