/* Dinno design tokens -------------------------------------------------- */
:root {
  --dinno-primary: #120686;
  --dinno-secondary: #E9F0FF;
  --dinno-neutral: #475569;
  --dinno-white: #FFFFFF;

  --dinno-success: #00D27A;
  --dinno-error: #D24200;
  --dinno-warning: #E5AC00;
  --dinno-success-soft: #E6FBF2;
  --dinno-error-soft: #FBECE5;
  --dinno-warning-soft: #FDF7E5;

  --dinno-font-family: 'Noto Sans Armenian', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Derived surfaces and lines, kept as tints of the brand tokens. */
  --line: rgba(71, 85, 105, 0.16);
  --line-strong: rgba(71, 85, 105, 0.28);
  --surface-sunken: #F7F9FE;
  --text-muted: rgba(71, 85, 105, 0.72);
  --text-faint: rgba(71, 85, 105, 0.5);
  --shadow-sm: 0 1px 2px rgba(18, 6, 134, 0.06), 0 1px 3px rgba(18, 6, 134, 0.04);
  --shadow-md: 0 4px 16px rgba(18, 6, 134, 0.10);
  --shadow-lg: 0 12px 40px rgba(18, 6, 134, 0.18);
  --radius: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

/* A class-level `display` beats the UA rule for [hidden], so enforce it here.
   Without this, a hidden login screen still reserves its full height. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--dinno-font-family);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: var(--dinno-neutral);
  background: var(--dinno-white);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--dinno-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; color: var(--dinno-primary); }

/* Typography scale ----------------------------------------------------- */
.title-lg { font-size: 22px; line-height: 28px; font-weight: 600; }
.title-md { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: 0.15px; }
.title-sm { font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: 0.1px; }
.body-sm  { font-size: 12px; line-height: 16px; letter-spacing: 0.4px; }
.label    { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.5px; }
.muted    { color: var(--text-muted); }
.faint    { color: var(--text-faint); }
.mono     { font-variant-numeric: tabular-nums; }

/* Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--dinno-primary);
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--dinno-primary); color: var(--dinno-white); }
.btn-primary:hover:not(:disabled) { background: #0d0466; }
.btn-secondary { border-color: var(--dinno-primary); }
.btn-secondary:hover:not(:disabled) { background: var(--dinno-secondary); }
.btn-soft { background: var(--dinno-secondary); }
.btn-soft:hover:not(:disabled) { background: #dbe6fd; }
.btn-ghost { color: var(--dinno-neutral); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-sunken); }
.btn-danger { color: var(--dinno-error); }
.btn-danger:hover:not(:disabled) { background: var(--dinno-error-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; line-height: 16px; }
.btn-icon { padding: 6px; border-radius: var(--radius-sm); }

/* Form controls -------------------------------------------------------- */
/* Every text-like input, so a new input type is never left unstyled. */
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=submit]),
select, textarea {
  font-family: inherit; font-size: 14px; line-height: 20px; color: var(--dinno-neutral);
  width: 100%; padding: 8px 10px; background: var(--dinno-white);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--dinno-primary);
  box-shadow: 0 0 0 3px rgba(18, 6, 134, 0.12);
}
.btn:focus-visible, a:focus-visible, [role=button]:focus-visible {
  outline: 2px solid var(--dinno-primary); outline-offset: 2px;
}
textarea { resize: vertical; min-height: 66px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23475569' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

.field { display: block; margin-bottom: 14px; }
.field > .label { display: block; margin-bottom: 5px; color: var(--dinno-neutral); }
.field .req { color: var(--dinno-error); }
.field-error { color: var(--dinno-error); margin-top: 4px; }
.field-hint { color: var(--text-faint); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 0; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--dinno-primary); flex: none; cursor: pointer; }
.check span { flex: 1; min-width: 0; }
.check .count { color: var(--text-faint); font-size: 12px; flex: none; }

/* App shell ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--dinno-white);
  border-bottom: 1px solid var(--line);
}
.topbar img { height: 26px; width: auto; display: block; }
.topbar .divider { width: 1px; height: 24px; background: var(--line); flex: none; }
.topbar .spacer { flex: 1; }
.brand { display: block; line-height: 0; }
.brand:hover { text-decoration: none; opacity: .85; }

/* Section navigation */
.mainnav { display: flex; align-items: center; gap: 2px; }
.nav-link {
  padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px;
  color: var(--text-muted);
}
.nav-link:hover { background: var(--surface-sunken); color: var(--dinno-primary); text-decoration: none; }
.nav-link[aria-current=page] { background: var(--dinno-secondary); color: var(--dinno-primary); }

/* Page container for the non-table pages */
.page { max-width: 1100px; padding: 24px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head h1 { color: var(--dinno-primary); }
.page-head > div:first-child { flex: 1; }
.page-foot { margin-top: 16px; max-width: 760px; }
.page-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(390px, 1fr)); gap: 16px;
  align-items: start; }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--dinno-white);
  box-shadow: var(--shadow-sm); overflow: hidden; }
.card-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px;
  border-bottom: 1px solid var(--line); background: var(--surface-sunken); }
.card-head > div:first-child { flex: 1; }
.card-body { padding: 16px 18px 18px; }
.add-row { display: flex; gap: 8px; }

.mini-scroll { max-height: 430px; overflow: auto; margin-top: 14px; }
.mini-table { width: 100%; min-width: 0; border-collapse: collapse; }
.mini-table thead th { position: sticky; top: 0; z-index: 1; background: var(--dinno-white); }
.mini-table th {
  text-align: left; padding: 6px 8px; background: transparent;
  font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.5px;
  color: var(--text-faint); text-transform: uppercase; border-bottom: 1px solid var(--line);
}
.mini-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mini-table tr:last-child td { border-bottom: none; }
.mini-table .name-cell { font-weight: 500; }
.mini-table .actions .btn { padding: 3px 7px; }

.link-btn { border: none; background: none; padding: 0; cursor: pointer; font-family: inherit;
  font-size: 14px; font-variant-numeric: tabular-nums; color: var(--dinno-primary);
  font-weight: 500; }
.link-btn:hover { text-decoration: underline; }

.tool-divider { width: 1px; height: 22px; background: var(--line); }
.history-by { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }

/* Block, not flex: the message is inline prose with <b>/<code> in it, and flex
   would turn each text fragment into its own column. */
.banner {
  padding: 10px 24px; font-size: 12px; line-height: 18px; letter-spacing: 0.4px;
  background: var(--dinno-warning-soft); color: #8a6800;
  border-bottom: 1px solid rgba(229, 172, 0, .35);
}
.banner code {
  padding: 1px 4px; border-radius: 4px; background: rgba(229, 172, 0, .18);
  font-size: 11px; overflow-wrap: anywhere;
}

.layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); align-items: start; }

/* Filters -------------------------------------------------------------- */
.filters {
  position: sticky; top: 51px; align-self: start;
  height: calc(100vh - 51px); overflow-y: auto;
  padding: 18px; border-right: 1px solid var(--line); background: var(--surface-sunken);
}
.filters h2 { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.filter-group { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.filter-group:last-child { border-bottom: none; margin-bottom: 0; }
.filter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.filter-head button { font-size: 12px; padding: 0; border: none; background: none;
  color: var(--dinno-primary); cursor: pointer; }
.filter-head button:hover { text-decoration: underline; }
.scroll-list { max-height: 230px; overflow-y: auto; margin-top: 4px; padding-right: 4px; }
.range-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.range-row .dash { color: var(--text-faint); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px; font-size: 12px; line-height: 16px; font-weight: 500;
  background: var(--dinno-secondary); color: var(--dinno-primary); border: none; cursor: pointer;
}
.chip:hover { background: #dbe6fd; }
.chip .x { font-size: 14px; line-height: 1; opacity: .6; }

/* Main ----------------------------------------------------------------- */
main { padding: 20px 24px 60px; min-width: 0; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.stat { display: flex; align-items: baseline; gap: 6px; }
.stat b { font-size: 22px; line-height: 28px; font-weight: 600; color: var(--dinno-primary);
  font-variant-numeric: tabular-nums; }
.sort-control { display: flex; align-items: center; gap: 6px; }
.sort-control select { width: auto; }

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto;
  background: var(--dinno-white); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
/* Only the wide scrolling data tables get a minimum width; the compact
   in-card tables must stay inside their card. */
.table-wrap table { min-width: 1060px; }
.page .table-wrap table { min-width: 820px; }
thead th {
  /* Not sticky: the wrapper scrolls horizontally, which breaks sticky offsets. */
  text-align: left; padding: 10px 14px; background: var(--surface-sunken);
  font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.5px;
  color: var(--text-muted); text-transform: uppercase; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--dinno-primary); }
thead th .arrow { opacity: .9; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(233, 240, 255, 0.45); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.date { white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { padding: 4px 7px; }
.entry-name { font-weight: 500; color: var(--dinno-primary); }
.entry-url { display: block; font-size: 12px; line-height: 16px; color: var(--text-faint);
  max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-cell { min-width: 190px; max-width: 340px; white-space: pre-wrap; overflow-wrap: anywhere; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap;
  background: var(--dinno-secondary); color: var(--dinno-primary);
}
.badge-quiet { background: var(--surface-sunken); color: var(--text-muted);
  border: 1px solid var(--line); }
.empty { padding: 56px 24px; text-align: center; }
.empty p { margin: 6px 0 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; }

/* Modals --------------------------------------------------------------- */
.scrim { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start;
  justify-content: center; padding: 40px 16px; overflow-y: auto;
  background: rgba(18, 6, 134, 0.28); backdrop-filter: blur(2px); }
.modal { width: 100%; max-width: 560px; background: var(--dinno-white);
  border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-lg { max-width: 900px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px;
  border-bottom: 1px solid var(--line); }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px;
  border-top: 1px solid var(--line); background: var(--surface-sunken); }
.modal-foot .spacer { flex: 1; }

.alert { padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; }
.alert-error { background: var(--dinno-error-soft); color: #9c3200; }
.alert-info { background: var(--dinno-secondary); color: var(--dinno-primary); }
.alert-success { background: var(--dinno-success-soft); color: #027a48; }
.alert-warning { background: var(--dinno-warning-soft); color: #8a6800; }

/* Import wizard -------------------------------------------------------- */
.dropzone { padding: 34px 20px; text-align: center; border: 2px dashed var(--line-strong);
  border-radius: var(--radius); background: var(--surface-sunken); cursor: pointer; }
.dropzone.over { border-color: var(--dinno-primary); background: var(--dinno-secondary); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px; margin-bottom: 18px; }
.summary-card { padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-sunken); border: 1px solid var(--line); }
.summary-card b { display: block; font-size: 22px; line-height: 28px; font-weight: 600;
  color: var(--dinno-primary); font-variant-numeric: tabular-nums; }
.section { margin-bottom: 20px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.section-head .spacer { flex: 1; }
.card-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px;
  overflow-y: auto; padding-right: 2px; }
.row-card { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.row-card.invalid { background: var(--dinno-error-soft); border-color: rgba(210, 66, 0, .3); }
.row-card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.row-card-head .spacer { flex: 1; }
.diff { display: grid; grid-template-columns: 24px 118px minmax(0, 1fr); gap: 8px;
  align-items: start; padding: 4px 0; }
.diff-label { font-weight: 500; font-size: 12px; line-height: 20px; }
.diff-values { display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 12px; line-height: 20px; }
.val-old { padding: 1px 6px; border-radius: 4px; background: var(--dinno-error-soft);
  color: #9c3200; text-decoration: line-through; }
.val-new { padding: 1px 6px; border-radius: 4px; background: var(--dinno-success-soft); color: #027a48; }
.val-empty { color: var(--text-faint); font-style: italic; }
.arrow-sep { color: var(--text-faint); }

/* Column mapping -------------------------------------------------------- */
.map-panel {
  margin-bottom: 18px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-sunken);
}
.map-panel > summary {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  cursor: pointer; list-style: none;
}
.map-panel > summary::-webkit-details-marker { display: none; }
.map-panel > summary::before {
  content: '▸'; color: var(--text-faint); font-size: 11px; transition: transform .12s;
}
.map-panel[open] > summary::before { transform: rotate(90deg); }
.map-panel-title { font-size: 14px; font-weight: 600; color: var(--dinno-primary); }

.map-grid { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(170px, 1.1fr) minmax(0, 1.4fr);
  gap: 8px 12px; align-items: center; }
.map-head { font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--text-faint); font-size: 11px; }
.map-row { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1;
  align-items: center; padding: 5px 0; border-top: 1px solid var(--line); }
.map-field { display: flex; flex-direction: column; gap: 1px; }
.map-field-name { white-space: nowrap; }
.map-conf { font-size: 11px; line-height: 15px; font-weight: 500; }
.conf-high { color: #027a48; }
.conf-medium { color: #8a6800; }
.conf-low { color: var(--dinno-error); }
.conf-none { color: var(--text-faint); }
.map-sample { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* Category / platform matching ----------------------------------------- */
.lookup-list { display: flex; flex-direction: column; gap: 6px; max-height: 380px;
  overflow-y: auto; padding-right: 2px; }
.lookup-item {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 1.15fr);
  gap: 10px 14px; align-items: center;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--dinno-white);
}
.lookup-value { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lookup-value b { overflow-wrap: anywhere; }
.lookup-choice { display: flex; flex-direction: column; gap: 6px; }
.lookup-newname { font-size: 13px; }

/* History -------------------------------------------------------------- */
.history-list { display: flex; flex-direction: column; gap: 2px; }
.history-item { display: grid; grid-template-columns: 158px minmax(0, 1fr); gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12px; line-height: 18px; }
.history-item:last-child { border-bottom: none; }

/* Lookup manager ------------------------------------------------------- */
.lookup-row { display: flex; align-items: center; gap: 8px; padding: 7px 0;
  border-bottom: 1px solid var(--line); }
.lookup-row:last-child { border-bottom: none; }
.lookup-row .name { flex: 1; min-width: 0; }
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--surface-sunken);
  border-radius: var(--radius-sm); margin-bottom: 14px; }
.tabs button { flex: 1; padding: 7px 12px; border: none; border-radius: 5px; cursor: pointer;
  background: transparent; font-family: inherit; font-size: 14px; font-weight: 500;
  color: var(--text-muted); }
.tabs button[aria-selected=true] { background: var(--dinno-white); color: var(--dinno-primary);
  box-shadow: var(--shadow-sm); }

/* Toast ---------------------------------------------------------------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { padding: 10px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  background: var(--dinno-primary); color: var(--dinno-white); font-size: 14px; font-weight: 500;
  max-width: 520px; }
.toast.err { background: var(--dinno-error); }

.mobile-only { display: none; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; height: auto; overflow: visible; border-right: none;
    border-bottom: 1px solid var(--line); }
  /* Collapsed by default on small screens so the table is not pushed off-screen. */
  .filters.collapsed .filter-group:not(:first-child) { display: none; }
  .filters.collapsed .filter-group:first-child { padding-bottom: 0; border-bottom: none; }
  .mobile-only { display: inline-block; }
  main { padding: 16px; }
  .toolbar { row-gap: 8px; }
}

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

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; padding: 10px 16px; gap: 10px; }
  .page { padding: 16px; }
  .account-name { display: none; }
  .mainnav { order: 3; width: 100%; }
  .nav-link { padding: 6px 10px; }
  .add-row { flex-wrap: wrap; }
  .map-grid { grid-template-columns: 1fr; }
  .map-row { display: block; }
  .map-head:not(:first-child) { display: none; }
  .map-sample { white-space: normal; margin-top: 2px; }
  .lookup-item { grid-template-columns: 1fr; }
  .mini-table td, .mini-table th { padding: 7px 5px; }
  .mini-table .actions .btn { padding: 3px 5px; }
  .topbar h1 { font-size: 16px; line-height: 24px; }
  .topbar img { height: 20px; }
  .topbar .divider { display: none; }
  .banner { padding: 10px 16px; }
}
