/* CADD UI kit -- the shared look for fast master / list pages in every
   panel (admin now; company, franchise later). Neutral base, the old
   caddtc.com colours (red, saffron, yellow on black and white) only as
   small accents. Pair with static/js/ui-kit.js and templates/ui/_kit.html.
   Everything is prefixed "uk-" so it never collides with older page CSS. */
:root {
  --uk-surface: #ffffff;
  --uk-soft: #f7f6f3;
  --uk-zebra: #fbfaf8;
  --uk-hover: #fff9ea;
  --uk-ink: #1b1b1f;
  --uk-ink-2: #45454d;
  --uk-ink-3: #75757f;
  --uk-line: #e8e6e1;
  --uk-line-2: #d5d2ca;
  --uk-red: #c62828;
  --uk-red-soft: #fdecea;
  --uk-saffron: #e8830c;
  --uk-saffron-ink: #9a4f00;
  --uk-saffron-soft: #fff1df;
  --uk-yellow: #f2b705;
  --uk-yellow-soft: #fff7d6;
  --uk-green: #2e7d32;
  --uk-green-soft: #e8f5e9;
  --uk-radius: 12px;
  --uk-focus: 0 0 0 3px rgba(232, 131, 12, .22);
}

/* ---------- page header ---------- */
.uk-page { max-width: 1180px; }
.uk-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px 20px; flex-wrap: wrap; margin: 0 0 16px; }
.uk-title { display: flex; align-items: center; gap: 10px; margin: 0; font: 600 20px/1.25 'Space Grotesk', system-ui, sans-serif; color: var(--uk-ink); }
.uk-title::before { content: ""; width: 4px; height: 22px; border-radius: 2px; flex: none;
  background: linear-gradient(180deg, var(--uk-red) 0%, var(--uk-saffron) 60%, var(--uk-yellow) 100%); }
.uk-count { font: 600 12px/1 'Work Sans', system-ui, sans-serif; color: var(--uk-ink-3); background: var(--uk-soft);
  border: 1px solid var(--uk-line); border-radius: 999px; padding: 4px 9px; font-variant-numeric: tabular-nums; }
.uk-sub { margin: 5px 0 0 14px; color: var(--uk-ink-3); font-size: 13px; max-width: 720px; line-height: 1.45; }
.uk-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- search ---------- */
.uk-search { position: relative; }
.uk-search input { width: 260px; height: 36px; padding: 0 34px 0 32px; border: 1px solid var(--uk-line-2); border-radius: 9px;
  font: inherit; font-size: 14px; color: var(--uk-ink); background: var(--uk-surface); }
.uk-search::before { content: ""; position: absolute; left: 11px; top: 50%; width: 11px; height: 11px; margin-top: -7px;
  border: 2px solid var(--uk-ink-3); border-radius: 50%; }
.uk-search::after { content: ""; position: absolute; left: 22px; top: 50%; width: 2px; height: 6px; margin-top: 2px;
  background: var(--uk-ink-3); transform: rotate(-45deg); border-radius: 1px; }
.uk-search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.uk-search input:focus + kbd, .uk-search input:not(:placeholder-shown) + kbd { display: none; }
kbd { font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--uk-ink-3); background: var(--uk-soft);
  border: 1px solid var(--uk-line-2); border-bottom-width: 2px; border-radius: 5px; padding: 3px 6px; }

/* ---------- form controls ---------- */
.uk-input, .uk-select { height: 36px; padding: 0 10px; border: 1px solid var(--uk-line-2); border-radius: 8px; background: var(--uk-surface);
  font: inherit; font-size: 14px; color: var(--uk-ink); min-width: 0; }
.uk-select { padding-right: 28px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background: var(--uk-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2375757f' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center; }
.uk-input:focus, .uk-select:focus, .uk-search input:focus, .uk-check input:focus-visible { outline: none; border-color: var(--uk-saffron); box-shadow: var(--uk-focus); }
.uk-input[type=number] { width: 84px; }
.uk-field { display: flex; flex-direction: column; gap: 4px; }
.uk-field > span { font-size: 11.5px; font-weight: 600; color: var(--uk-ink-3); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- buttons ---------- */
.uk-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid transparent; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, color .12s; }
.uk-btn-primary { background: var(--uk-ink); color: #fff; }
.uk-btn-primary:hover { background: #000; color: #fff; }
.uk-btn-ghost { background: var(--uk-surface); color: var(--uk-ink-2); border-color: var(--uk-line-2); }
.uk-btn-ghost:hover { background: var(--uk-soft); color: var(--uk-ink); }
.uk-btn-accent { background: var(--uk-saffron-soft); color: var(--uk-saffron-ink); border-color: #f6d3a8; }
.uk-btn-accent:hover { background: #ffe6c7; color: var(--uk-saffron-ink); }
.uk-btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.uk-btn-link { background: none; border: 0; height: 28px; padding: 0 8px; border-radius: 6px; color: var(--uk-ink-2); font-weight: 600; font-size: 12.5px; }
.uk-btn-link:hover { background: var(--uk-soft); color: var(--uk-ink); }
.uk-btn-danger { color: var(--uk-red); }
.uk-btn-danger:hover { background: var(--uk-red-soft); color: var(--uk-red); }
.uk-btn:disabled, .uk-btn[aria-disabled=true] { opacity: .45; cursor: not-allowed; }
.uk-btn:focus-visible, .uk-btn-link:focus-visible { outline: none; box-shadow: var(--uk-focus); }

/* ---------- card, add bar, notes ---------- */
.uk-card { background: var(--uk-surface); border: 1px solid var(--uk-line); border-radius: var(--uk-radius); overflow: hidden; }
.uk-card + .uk-card { margin-top: 16px; }
.uk-split > .uk-card { margin-top: 0; }
.uk-card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--uk-line); font-weight: 600; font-size: 14px; }
.uk-addbar { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 14px; background: var(--uk-zebra);
  border-bottom: 1px solid var(--uk-line); }
.uk-addbar .uk-grow { flex: 1 1 220px; }
.uk-addbar .uk-hint { font-size: 12px; color: var(--uk-ink-3); align-self: center; }
.uk-note { font-size: 12.5px; color: var(--uk-ink-3); padding: 10px 14px; }
.uk-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--uk-line); }

/* ---------- table ---------- */
.uk-table-wrap { overflow: auto; max-height: calc(100vh - 250px); min-height: 120px; }
table.uk-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.uk-table th { position: sticky; top: 0; z-index: 2; background: var(--uk-soft); text-align: left; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--uk-ink-3);
  padding: 9px 12px; border-bottom: 1px solid var(--uk-line); }
.uk-table td { padding: 7px 12px; border-bottom: 1px solid #f0eee9; color: var(--uk-ink); vertical-align: middle; height: 40px; }
.uk-table tbody tr:nth-child(even) td { background: var(--uk-zebra); }
.uk-table tbody tr:hover td { background: var(--uk-hover); }
.uk-table tbody tr:last-child td { border-bottom: 0; }
.uk-table .uk-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--uk-ink-2); white-space: nowrap; }
.uk-table .uk-muted { color: var(--uk-ink-3); }
.uk-table .uk-idx { width: 1%; color: var(--uk-ink-3); font-variant-numeric: tabular-nums; }
.uk-table .uk-actions { width: 1%; text-align: right; white-space: nowrap; }
.uk-table tr.is-editing td { background: var(--uk-yellow-soft) !important; }
.uk-table tr.is-new td { animation: uk-flash 1.6s ease-out; }
.uk-table tr.is-gone { opacity: 0; transition: opacity .25s; }
.uk-table td .uk-input { height: 30px; width: 100%; font-size: 13.5px; }
.uk-table td .uk-input[type=number] { width: 80px; }
.uk-table tr.uk-group td { background: var(--uk-soft) !important; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--uk-ink-2); height: 32px; }
.uk-table tr.uk-group td .uk-count { margin-left: 6px; }
.uk-empty td, td.uk-empty { text-align: center; color: var(--uk-ink-3); padding: 28px 12px !important; height: auto; }
@keyframes uk-flash { from { background: var(--uk-yellow-soft); } to { background: transparent; } }

/* ---------- badges ---------- */
.uk-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px;
  font-weight: 600; line-height: 1.55; white-space: nowrap; vertical-align: middle; }
.uk-badge-current { background: var(--uk-saffron-soft); color: var(--uk-saffron-ink); }
.uk-badge-current::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--uk-saffron); }
.uk-badge-ok { background: var(--uk-green-soft); color: var(--uk-green); }
.uk-badge-off { background: var(--uk-soft); color: var(--uk-ink-3); border: 1px solid var(--uk-line); }
.uk-badge-red { background: var(--uk-red-soft); color: var(--uk-red); }
.uk-badge-yellow { background: var(--uk-yellow-soft); color: #7a5b00; }

/* ---------- pager ---------- */
.uk-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px;
  border-top: 1px solid var(--uk-line); font-size: 12.5px; color: var(--uk-ink-3); }
.uk-pager nav { display: flex; gap: 4px; align-items: center; }
.uk-pager button[aria-current=page] { background: var(--uk-ink); color: #fff; border-color: var(--uk-ink); }

/* ---------- checkbox lists (standard designations etc.) ---------- */
.uk-checks { max-height: calc(100vh - 300px); overflow: auto; }
.uk-check-group { border-bottom: 1px solid var(--uk-line); }
.uk-check-group:last-child { border-bottom: 0; }
.uk-check-group > header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 14px; background: var(--uk-soft); font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--uk-ink-2); }
.uk-check-group > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2px 10px; padding: 8px 14px 10px; }
.uk-check { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 7px; font-size: 13.5px; cursor: pointer; color: var(--uk-ink); }
.uk-check:hover { background: var(--uk-hover); }
.uk-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--uk-ink); flex: none; }
.uk-check.is-added { color: var(--uk-ink-3); cursor: default; }
.uk-check.is-added:hover { background: none; }
.uk-check small { color: var(--uk-ink-3); font-size: 11px; }

/* ---------- layout helpers ---------- */
.uk-split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; align-items: start; }
.uk-hidden { display: none !important; }
@media (max-width: 1000px) { .uk-split { grid-template-columns: 1fr; } }

/* ---------- toasts + confirm ---------- */
.uk-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px;
  max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.uk-toast { pointer-events: auto; background: var(--uk-ink); color: #fff; font-size: 13.5px; line-height: 1.4; padding: 10px 14px 10px 12px;
  border-radius: 10px; border-left: 4px solid #66bb6a; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); animation: uk-in .18s ease-out; }
.uk-toast.is-err { border-left-color: #ef5350; }
.uk-toast.is-out { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes uk-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.uk-modal { position: fixed; inset: 0; z-index: 1001; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(20, 20, 24, .35); }
.uk-modal > div { background: #fff; border-radius: 14px; padding: 20px; width: min(400px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.uk-modal p { margin: 0 0 18px; font-size: 14.5px; line-height: 1.45; color: var(--uk-ink); }
.uk-modal footer { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- sidebar sections (panel nav) ---------- */
.panel-sidebar nav .uk-nav-h { padding: 14px 12px 4px; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--uk-ink-3); }
.panel-sidebar nav .uk-nav-h:first-child { padding-top: 4px; }
.panel-sidebar nav a.active { box-shadow: inset 3px 0 0 var(--uk-red); }

/* ---------- small text helpers ---------- */
.uk-small { font-size: 12px; }
.uk-muted { color: var(--uk-ink-3); }
.uk-nowrap { white-space: nowrap; }
.uk-clip { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uk-table td.uk-name-cell { min-width: 140px; }
.uk-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.uk-code { font: 500 12.5px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--uk-soft); border: 1px solid var(--uk-line);
  border-radius: 5px; padding: 1px 6px; color: var(--uk-ink-2); }
.uk-strong-link { color: var(--uk-ink); font-weight: 600; text-decoration: none; }
.uk-strong-link:hover { color: var(--uk-red); text-decoration: underline; }
.uk-alert { background: var(--uk-red-soft); color: var(--uk-red); border: 1px solid #f5c6c2; border-radius: 10px; padding: 10px 14px;
  font-size: 13.5px; margin: 0 0 14px; }

/* ---------- logos (institute list / form) ---------- */
.uk-logo { display: inline-block; width: 36px; height: 36px; object-fit: contain; border-radius: 8px; background: #fff;
  border: 1px solid var(--uk-line); vertical-align: middle; }
.uk-logo[hidden] { display: none; }
.uk-logo-txt { display: inline-flex; align-items: center; justify-content: center; background: var(--uk-saffron-soft);
  color: var(--uk-saffron-ink); font-weight: 700; font-size: 15px; border-color: #f6d3a8; }
.uk-table td.uk-logo-cell { width: 1%; padding-right: 0; }
.uk-logo-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 36px; }
.uk-logo-pick .uk-logo { width: 64px; height: 64px; }
.uk-logo-pick input[type=file] { font-size: 13px; }

/* ---------- full forms ---------- */
.uk-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; padding: 16px 14px 18px; }
.uk-form .uk-span-2 { grid-column: 1 / -1; }
.uk-form .uk-field > span { text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--uk-ink-2); }
.uk-form .uk-input { width: 100%; }
.uk-textarea { height: auto; min-height: 64px; padding: 8px 10px; line-height: 1.45; resize: vertical; }
.uk-req { color: var(--uk-red); font-weight: 700; }
.uk-err-text, .uk-hint-text { font-style: normal; font-size: 12px; }
.uk-err-text { color: var(--uk-red); font-weight: 600; }
.uk-hint-text { color: var(--uk-ink-3); }
.uk-field.has-err .uk-input { border-color: var(--uk-red); background: #fffafa; }
.uk-card-h-mid { border-top: 1px solid var(--uk-line); background: var(--uk-zebra); }
.uk-form-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--uk-line); background: var(--uk-zebra); }
.uk-inst-strip { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 16px; }
.uk-inst-strip-id { display: flex; align-items: center; gap: 12px; }
.uk-inst-strip dl { display: flex; gap: 24px; margin: 0; }
.uk-inst-strip dt { font-size: 11.5px; color: var(--uk-ink-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.uk-inst-strip dd { margin: 2px 0 0; font-weight: 600; font-size: 15px; }

/* ---------- dashboard: stat tiles ---------- */
.uk-dash { max-width: 1240px; }
.uk-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.uk-tile { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--uk-surface); border: 1px solid var(--uk-line);
  border-radius: var(--uk-radius); color: var(--uk-ink); text-decoration: none; min-width: 0; }
a.uk-tile:hover { border-color: var(--uk-line-2); background: var(--uk-zebra); }
.uk-tile-label { font-size: 12.5px; color: var(--uk-ink-3); font-weight: 600; }
.uk-tile-value { font: 600 26px/1.15 'Work Sans', system-ui, sans-serif; color: var(--uk-ink); }
.uk-tile-sub { font-size: 12px; line-height: 1.35; color: var(--uk-ink-3); }
.uk-tile-warn { box-shadow: inset 3px 0 0 var(--uk-yellow); }
.uk-dash-row { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.uk-dash-row > .uk-card + .uk-card { margin-top: 0; }
.uk-table tfoot td { padding: 9px 12px; border-top: 1px solid var(--uk-line); background: var(--uk-soft); font-weight: 600; }
.uk-table th small { font-weight: 500; text-transform: none; letter-spacing: 0; }

/* ---------- dashboard: column chart (inline SVG) ---------- */
.uk-chart { position: relative; padding: 10px 14px 4px; }
.uk-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.uk-chart .uk-grid { stroke: #eceae4; stroke-width: 1; shape-rendering: crispEdges; }
.uk-chart .uk-axis { stroke: var(--uk-line-2); stroke-width: 1; shape-rendering: crispEdges; }
.uk-chart .uk-tick { fill: var(--uk-ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.uk-chart .uk-tick-cur { fill: var(--uk-ink); font-weight: 600; }
.uk-chart .uk-val { fill: var(--uk-ink-2); font-size: 11.5px; font-weight: 600; }
.uk-chart .uk-bar { fill: #d0700a; transition: fill .12s; }
.uk-chart .uk-hit { fill: transparent; }
.uk-chart .uk-col { cursor: default; outline: none; }
.uk-chart .uk-col.is-on .uk-hit, .uk-chart .uk-col:focus-visible .uk-hit { fill: rgba(232, 131, 12, .07); }
.uk-chart .uk-col.is-on .uk-bar { fill: #b35f06; }
.uk-tip { position: absolute; z-index: 3; pointer-events: none; display: flex; flex-direction: column; gap: 1px; padding: 7px 10px;
  background: var(--uk-ink); color: #fff; border-radius: 8px; font-size: 12px; line-height: 1.35; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.uk-tip[hidden] { display: none; }
.uk-tip b { font-size: 13px; }
.uk-tip span, .uk-tip small { color: #d6d5d0; font-size: 11.5px; }
.uk-chart-table { border-top: 1px solid var(--uk-line); }
.uk-chart-table summary { cursor: pointer; padding: 9px 14px; font-size: 12.5px; color: var(--uk-ink-2); font-weight: 600; }
.uk-chart-table[open] summary { border-bottom: 1px solid var(--uk-line); }

/* ---------- dashboard: attention list ---------- */
.uk-attn { list-style: none; margin: 0; padding: 4px 0; }
.uk-attn li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 14px; font-size: 13.5px; line-height: 1.4; border-bottom: 1px solid #f0eee9; }
.uk-attn li:last-child { border-bottom: 0; }
.uk-attn li .uk-badge { flex: none; min-width: 84px; justify-content: center; }
.uk-attn a { color: var(--uk-ink); font-weight: 600; }
@media (max-width: 1320px) { .uk-hide-md { display: none; } }
@media (max-width: 1000px) { .uk-dash-row { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .uk-form { grid-template-columns: 1fr; }
  .uk-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .uk-tile-value { font-size: 22px; }
}

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .panel-shell { flex-direction: column; }
  .panel-sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--uk-line); }
  .panel-sidebar nav { max-height: 46vh; overflow: auto; }
  .panel-topbar { padding: 12px 16px; }
  .panel-content { padding: 16px; }
  .uk-search, .uk-search input { width: 100%; }
  .uk-tools { width: 100%; }
  .uk-addbar > * { flex: 1 1 100%; }
  .uk-table-wrap { max-height: none; }
  .uk-hide-sm { display: none; }
}
