/* LAN Excel Portal — giao diện dữ liệu hiện đại (pro data platform).
   Tự chứa 100%: không CDN, không remote font/CSS/JS. Bảng màu slate/indigo/emerald/amber. */

:root {
  /* ink & text */
  --fg: #0f172a;
  --fg-soft: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;

  /* surfaces */
  --bg: #f8fafc;
  --bg-deep: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --line-soft: #eef2f7;

  /* accents */
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-strong: #4338ca;
  --accent-violet: #7c3aed;
  --accent-soft: #eef2ff;
  --accent-soft-2: #f5f3ff;

  --ok: #059669;
  --ok-2: #10b981;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-ink: #92400e;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  /* chrome */
  --topbar-bg: #0f172a;
  --topbar-bg-2: #1e293b;
  --topbar-fg: #e2e8f0;

  /* shape */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  /* elevation layering */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .05), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 1px 3px rgba(15, 23, 42, .05), 0 10px 15px -3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, .12), 0 8px 10px -6px rgba(15, 23, 42, .08);
  --ring: 0 0 0 3px rgba(99, 102, 241, .18);

  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  min-height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 420px at 12% -8%, rgba(99, 102, 241, .07), transparent 60%),
    radial-gradient(1000px 380px at 100% 0%, rgba(16, 185, 129, .06), transparent 55%);
  background-attachment: fixed;
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }

::selection { background: rgba(99, 102, 241, .22); }

/* ------------------------------------------------------------- chrome / topbar */

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus {
  left: .6rem; top: .6rem; z-index: 200; padding: .55rem .9rem;
  background: #fff; color: var(--fg); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(180deg, var(--topbar-bg) 0%, var(--topbar-bg-2) 100%);
  color: var(--topbar-fg);
  border-bottom: 1px solid rgba(148, 163, 184, .14);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04), 0 8px 24px -12px rgba(2, 6, 23, .55);
  backdrop-filter: saturate(140%) blur(6px);
}
.topbar::after {
  content: ""; display: block; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, .75), rgba(16, 185, 129, .6), transparent);
  opacity: .75;
}
.topbar-inner {
  width: 100%;
  display: flex; flex-wrap: wrap; gap: .6rem 1.35rem;
  align-items: center; justify-content: space-between;
  padding: .6rem 1.4rem;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 10px;
  background: linear-gradient(140deg, var(--accent-2), var(--accent-violet) 70%, #a855f7);
  color: #fff;
  box-shadow: 0 4px 12px -2px rgba(99, 102, 241, .55), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.brand-mark svg { width: 1.15rem; height: 1.15rem; display: block; }
.brand a { font-weight: 700; color: #fff; letter-spacing: .2px; font-size: 1.02rem; }
.brand a:hover { text-decoration: none; color: #c7d2fe; }

.mainnav { display: flex; flex-wrap: wrap; gap: .28rem .35rem; align-items: center; }
.navpill {
  color: #cbd5e1; padding: .34rem .72rem; border-radius: var(--radius-pill);
  font-size: .9rem; font-weight: 500; border: 1px solid transparent;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.navpill:hover { background: rgba(148, 163, 184, .16); color: #fff; text-decoration: none; }
.navpill.active {
  background: linear-gradient(140deg, var(--accent), var(--accent-violet));
  color: #fff; border-color: rgba(255, 255, 255, .12);
  box-shadow: 0 4px 12px -4px rgba(99, 102, 241, .7);
}
.who {
  color: #e2e8f0; font-size: .9rem; display: inline-flex; align-items: center; gap: .45rem;
  padding-left: .55rem; margin-left: .15rem; border-left: 1px solid rgba(148, 163, 184, .25);
}
.role-badge {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  background: rgba(16, 185, 129, .16); color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, .35);
  padding: .12rem .5rem; border-radius: var(--radius-pill);
}
.link-btn { border: none; background: none; color: #c7d2fe; padding: 0; font-weight: 600; font: inherit; cursor: pointer; }
.link-btn:hover { color: #fff; text-decoration: underline; background: none; }
.inline { display: inline; }

/* ------------------------------------------------------------- layout (full-width) */

.container { width: 100%; max-width: 100%; margin: 0; padding: 1rem 1.4rem 1.75rem; }
.footer {
  width: 100%; max-width: 100%;
  padding: 1rem 1.4rem 1.75rem; color: var(--muted); font-size: .85rem;
  border-top: 1px solid var(--line); margin-top: 1.25rem;
}

h1 { font-size: 1.45rem; margin: .1rem 0 .4rem; letter-spacing: -.015em; font-weight: 700; }
h2 { font-size: 1.06rem; margin: 1.15rem 0 .55rem; letter-spacing: -.01em; }
h3 { font-size: .98rem; margin: 0 0 .3rem; }

.hint { color: var(--muted); font-size: .9rem; }
.num { font-variant-numeric: tabular-nums; }
.mono, code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .88em;
}
code {
  background: var(--bg-deep); color: var(--fg-soft);
  padding: .08rem .38rem; border-radius: 6px; border: 1px solid var(--line-soft);
}
.wrap { overflow-wrap: anywhere; }

.page-head {
  display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-start;
  justify-content: space-between; margin-bottom: .7rem;
}
.dataset-head { align-items: center; }
.dataset-title h1 { margin-bottom: .15rem; }

.pill {
  background: linear-gradient(140deg, var(--accent-soft), var(--accent-soft-2));
  color: var(--accent-strong); border: 1px solid #c7d2fe;
  padding: .12rem .55rem; border-radius: var(--radius-pill); font-size: .82rem; font-weight: 600;
}
.badge {
  font-size: .7rem; font-weight: 600; background: #eef2f6; color: var(--muted);
  padding: .1rem .45rem; border-radius: var(--radius-pill); white-space: nowrap;
  border: 1px solid var(--line); display: inline-block;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #a7f3d0; }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: #fde68a; }

.alert {
  position: relative; border-radius: var(--radius-sm); padding: .65rem .9rem .65rem 2.2rem;
  margin: .55rem 0 1rem; border: 1px solid var(--line); font-size: .92rem; box-shadow: var(--shadow-xs);
}
.alert::before { position: absolute; left: .75rem; top: .62rem; font-weight: 700; }
.alert-warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn-ink); }
.alert-warn::before { content: "⚠"; }
.alert-error, .error { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); font-weight: 600; }
.alert-error::before { content: "✕"; }
.error { padding: .65rem .9rem; border-radius: var(--radius-sm); border: 1px solid #fecaca; }
.alert-info { background: var(--accent-soft); border-color: #c7d2fe; color: var(--accent-strong); }
.alert-info::before { content: "ℹ"; }
.empty {
  padding: 1.6rem; text-align: center; color: var(--muted);
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
}

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

/* ------------------------------------------------------------- flash */

.flash { list-style: none; padding: 0; margin: 0 0 .9rem; }
.flash li {
  position: relative; padding: .6rem .9rem .6rem 2.3rem; border-radius: var(--radius-sm);
  margin-bottom: .45rem; border: 1px solid transparent; box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.flash li::before { position: absolute; left: .8rem; top: .58rem; font-weight: 800; }
.flash li::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.flash-success { background: var(--ok-soft); color: #065f46; border-color: #a7f3d0; }
.flash-success::before { content: "✓"; color: var(--ok); }
.flash-success::after { background: linear-gradient(180deg, var(--ok-2), var(--ok)); }
.flash-error { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.flash-error::before { content: "✕"; color: var(--danger); }
.flash-error::after { background: linear-gradient(180deg, #f87171, var(--danger)); }
.flash-info { background: var(--accent-soft); color: var(--accent-strong); border-color: #c7d2fe; }
.flash-info::before { content: "ℹ"; color: var(--accent); }
.flash-info::after { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }

/* ------------------------------------------------------------- panels & cards */

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem 1.2rem; margin: 0 0 1.1rem; box-shadow: var(--shadow-sm);
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(262px, 1fr)); gap: 1rem; }
.card-grid.wide { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.mini-card, .card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1.05rem; box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.mini-card:hover, .card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow);
  border-color: #c7d2fe;
}
.mini-card .action-row, .card .action-row { margin-top: .65rem; }
.dataset-card h2 { margin: 0 0 .35rem; }
.dataset-card h2 a { letter-spacing: -.01em; }

.record-head { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .4rem; }
.record-head h2 { margin: 0; font-size: 1.02rem; }
.record-id {
  font-size: .72rem; font-weight: 700; color: #fff;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  padding: .12rem .5rem; border-radius: var(--radius-pill); white-space: nowrap;
  box-shadow: 0 2px 6px -2px rgba(79, 70, 229, .6);
}
.record-fields { display: grid; grid-template-columns: minmax(90px, 34%) 1fr; gap: 0 .7rem; margin: .4rem 0; font-size: .89rem; }
.record-fields dt, .record-fields dd {
  border-bottom: 1px solid var(--line-soft); padding: .4rem .2rem;
  align-items: baseline; min-width: 0;
}
.record-fields dt { color: var(--muted); font-weight: 500; }
.record-fields dd { margin: 0; overflow-wrap: anywhere; }
.record-fields dt:last-of-type, .record-fields dd:last-of-type { border-bottom: none; }

.tiles { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .85rem; padding: 0; }
.tiles li {
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem; display: flex; flex-direction: column; gap: .2rem; box-shadow: var(--shadow-sm);
}
.tiles strong { font-size: 1.4rem; letter-spacing: -.02em; }
.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .35rem .9rem; }
.detail { max-width: 40rem; overflow-wrap: anywhere; font-size: .84rem; }

/* ------------------------------------------------------------- tables */

table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line-soft);
  padding: .46rem .65rem; text-align: left; vertical-align: top;
}
table.grid th:first-child, table.grid td:first-child { border-left: 1px solid var(--line-soft); }
table.grid thead th {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  position: sticky; top: 0; z-index: 3;
  font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
  color: #334155; font-weight: 700;
  border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
}
table.grid thead th a { color: #334155; display: inline-flex; align-items: center; gap: .25rem; }
table.grid thead th a:hover { color: var(--accent); }
table.grid tbody tr:nth-child(even) > * { background: #fbfcfe; }
table.grid tbody tr { transition: background .12s var(--ease); }
table.grid tbody tr:hover > * { background: #eef2ff; }
table.grid tbody th[scope="row"] { font-weight: 700; color: var(--fg-soft); }

/* table grows to content width so wide datasets scroll horizontally instead
   of squeezing columns until words break mid-syllable */
table.grid.data-grid { width: max-content; min-width: 100%; }
/* Nhãn cột dài ("Địa chỉ thường trú - Xã/ Phường", "Phạm vi hành nghề đăng ký,
   đề nghị của công dân"…) xuống dòng gọn thay vì trải ngang 1 dòng rất rộng. */
.data-grid thead th {
  white-space: normal; line-height: 1.25;
  max-width: 11rem; min-width: 4.2rem;
  padding: .36rem .45rem; vertical-align: middle;
}
.data-grid thead th a { justify-content: center; text-align: center; }

/* scroll region uses most of the screen height */
.scroll {
  overflow: auto;
  max-height: calc(100vh - 175px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.scroll.short { max-height: 40vh; }
.preview-scroll { max-height: calc(100vh - 320px); }
.table-scroll { max-height: calc(100vh - 235px); }

/* sticky ID (left) + Thao tác (right) columns with soft separation shadow */
.data-grid .sticky-left { position: sticky; left: 0; z-index: 2; }
.data-grid thead .sticky-left { z-index: 4; }
.data-grid .sticky-right { position: sticky; right: 0; z-index: 2; }
.data-grid thead .sticky-right { z-index: 4; }
.data-grid tbody .sticky-left, .data-grid tbody .sticky-right { background: var(--card); }
.data-grid tbody tr:nth-child(even) .sticky-left,
.data-grid tbody tr:nth-child(even) .sticky-right { background: #fbfcfe; }
.data-grid tbody tr:hover .sticky-left, .data-grid tbody tr:hover .sticky-right { background: #eef2ff; }
.data-grid .col-id {
  width: 4.75rem; text-align: right;
  box-shadow: 6px 0 8px -8px rgba(15, 23, 42, .35), 1px 0 0 var(--line);
}
.data-grid .sticky-right {
  box-shadow: -6px 0 8px -8px rgba(15, 23, 42, .35), -1px 0 0 var(--line);
  white-space: nowrap;
}
.data-grid thead .sticky-left { box-shadow: 6px 0 8px -8px rgba(15, 23, 42, .35), 1px 0 0 var(--line); }
.data-grid thead .sticky-right { box-shadow: -6px 0 8px -8px rgba(15, 23, 42, .35), -1px 0 0 var(--line); }
.data-grid td.cell { max-width: 18rem; min-width: 5rem; overflow-wrap: anywhere; }

/* Bảng CCHND của Hội đồng (27 cột) rất rộng ⇒ thu gọn mạnh độ rộng cột để nhìn
   được nhiều cột hơn. Nội dung vẫn nằm NGUYÊN trong DOM (`data-value` +
   `.cell-text`) nên bấm sửa trực tiếp và test không đổi hành vi. */
.table-scroll[data-slug="cchnd_tham_dinh"] .data-grid,
.table-scroll[data-slug="ot_37"] .data-grid { font-size: .84rem; }
.table-scroll[data-slug="cchnd_tham_dinh"] .data-grid th,
.table-scroll[data-slug="cchnd_tham_dinh"] .data-grid td,
.table-scroll[data-slug="ot_37"] .data-grid th,
.table-scroll[data-slug="ot_37"] .data-grid td { padding: .34rem .45rem; }
.table-scroll[data-slug="cchnd_tham_dinh"] .data-grid .col-id,
.table-scroll[data-slug="ot_37"] .data-grid .col-id { width: 3.2rem; }
.table-scroll[data-slug="cchnd_tham_dinh"] .data-grid td.cell,
.table-scroll[data-slug="ot_37"] .data-grid td.cell { max-width: 12rem; min-width: 4rem; }

/* Độ rộng gọn theo LOẠI cột — `th` và `td` đều mang `data-col`.
   `:is(...)` giữ specificity cao hơn rule `.data-grid td.cell` ở trên. */
:is(.table-scroll[data-slug="cchnd_tham_dinh"], .table-scroll[data-slug="ot_37"]) .data-grid [data-col="stt"] {
  width: 3.2rem; min-width: 2.8rem; max-width: 3.8rem; text-align: center;
}
:is(.table-scroll[data-slug="cchnd_tham_dinh"], .table-scroll[data-slug="ot_37"]) .data-grid
  :is(
    [data-col="ngay_thang_nam_sinh"], [data-col="so_the_can_cuoc_so"],
    [data-col="ngay_cap"], [data-col="tinh_thanh_pho"], [data-col="so_cchnd"],
    [data-col="ngay_cap_van_bang"], [data-col="ngay_bat_au_thuc_hanh"],
    [data-col="ngay_bat_dau_thuc_hanh"], [data-col="ngay_ket_thuc_thuc_hanh"],
    [data-col="ket_luan_cua_hoi_ong"], [data-col="ket_luan_cua_hoi_dong"],
    [data-col="thoi_gian_bat_au_hop"], [data-col="thoi_gian_ket_thuc_hop"],
    [data-col="phan_cong_xem_luot_1"], [data-col="phan_cong_xem_luot_2"]
  ) { max-width: 7.5rem; min-width: 4.5rem; }
:is(.table-scroll[data-slug="cchnd_tham_dinh"], .table-scroll[data-slug="ot_37"]) .data-grid
  :is(
    [data-col="ho_ten"], [data-col="ma_ho_so"], [data-col="trinh_o_chuyen_mon"],
    [data-col="trinh_do_chuyen_mon"], [data-col="noi_cap"]
  ) { max-width: 10.5rem; min-width: 6rem; }
:is(.table-scroll[data-slug="cchnd_tham_dinh"], .table-scroll[data-slug="ot_37"]) .data-grid
  :is(
    [data-col="ghi_chu_hoi_ong"], [data-col="ghi_chu_thay_the"],
    [data-col="ghi_chu_thay_the_ieu_chinh"],
    [data-col="pham_vi_hanh_nghe_ang_ky_e_nghi_cua_cong_dan"],
    [data-col="pham_vi_hoat_ong_chuyen_mon"]
  ) { max-width: 15rem; min-width: 8rem; }
/* Cột nội dung dài: cuộn gọn trong ô thay vì kéo dài cả bảng. */
:is(.table-scroll[data-slug="cchnd_tham_dinh"], .table-scroll[data-slug="ot_37"]) .data-grid
  :is(
    [data-col="ghi_chu_hoi_ong"], [data-col="ghi_chu_thay_the"],
    [data-col="ghi_chu_thay_the_ieu_chinh"],
    [data-col="pham_vi_hanh_nghe_ang_ky_e_nghi_cua_cong_dan"],
    [data-col="pham_vi_hoat_ong_chuyen_mon"]
  ) .cell-text { display: block; max-height: 5.4rem; overflow-y: auto; }

/* editable cell affordance */
.cell-editable { cursor: pointer; position: relative; }
.cell-editable:hover {
  outline: 1px solid var(--accent-2); outline-offset: -2px;
  background: var(--accent-soft-2) !important;
}
.cell-pencil { opacity: 0; margin-left: .35rem; font-size: .78rem; transition: opacity .12s var(--ease); }
.cell-editable:hover .cell-pencil, .cell-editable:focus .cell-pencil { opacity: .8; }
.cell.editing { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff !important; }
.cell.editing .cell-pencil { display: none; }
.cell-input {
  width: 100%; min-width: 6rem; font: inherit; padding: .2rem .4rem;
  border: 1px solid var(--accent); border-radius: 6px; background: #fff;
  box-shadow: var(--ring);
}
.cell.saving { opacity: .6; }

.rowno { width: 3rem; text-align: right; color: var(--muted); }

/* ------------------------------------------------------------- forms */

.toolbar, .inline-form, .card-form, .import-form, .grant-form {
  display: flex; flex-wrap: wrap; gap: .65rem 1rem; align-items: flex-end;
}
.toolbar {
  margin: 0 0 .9rem; background: linear-gradient(180deg, #ffffff, #fbfcff);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .65rem .85rem; box-shadow: var(--shadow-sm);
}
.toolbar-field { display: flex; align-items: center; }
.field { display: flex; flex-direction: column; gap: .25rem; margin: .35rem 0; }
.field.compact { margin: 0; }
.field label { font-weight: 600; font-size: .85rem; color: #334155; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .9rem 1.3rem; width: 100%; }
.form-grid .field { margin: 0; min-width: 0; }
.form-grid .field.field-wide { grid-column: span 2; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; min-width: 0; }
.form-grid textarea { resize: vertical; }
.card-form { width: 100%; }
.field-locked input, .field-locked textarea { background: var(--bg-deep); color: var(--muted); }

/* search box with icon */
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box .search-icon {
  position: absolute; left: .55rem; width: 1rem; height: 1rem;
  color: var(--muted-2); pointer-events: none;
}
.search-box input[type="search"] { padding-left: 2.1rem; }

/* Auto-growing textarea for long cell values (height set by portal.js). */
textarea.auto-grow { overflow: hidden; line-height: 1.4; }

@media (max-width: 720px) {
  .form-grid .field.field-wide { grid-column: auto; }
}

fieldset {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin: .85rem 0; padding: .7rem 1rem; background: linear-gradient(180deg, #ffffff, #fcfdff);
}
legend { font-weight: 700; padding: 0 .4rem; color: #334155; }
label { font-weight: 500; }

input[type="text"], input[type="password"], input[type="search"], input[type="file"],
input[type="number"], select, textarea {
  padding: .46rem .6rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: inherit; background: #fff; min-width: 12rem; color: var(--fg);
  box-shadow: var(--shadow-xs);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: #b6c2d1; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-2);
  box-shadow: var(--ring), var(--shadow-xs);
  background: #fff;
}
textarea { min-width: 24rem; }
input[type="file"] { padding: .38rem; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }

/* ------------------------------------------------------------- buttons */

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .46rem .85rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; cursor: pointer; text-decoration: none; color: var(--fg-soft);
  font: inherit; font-weight: 600; line-height: 1.2; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background .15s var(--ease), border-color .15s var(--ease),
              box-shadow .15s var(--ease), transform .06s var(--ease), color .15s var(--ease);
}
button:hover, .button:hover { background: var(--bg-deep); text-decoration: none; box-shadow: var(--shadow-sm); }
button:active, .button:active { transform: translateY(1px); }
button:focus-visible, .button:focus-visible { outline: none; box-shadow: var(--ring); }

button.primary, .button.primary {
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  color: #fff; border-color: var(--accent);
  box-shadow: 0 4px 12px -4px rgba(79, 70, 229, .6), inset 0 1px 0 rgba(255, 255, 255, .18);
}
button.primary:hover, .button.primary:hover {
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  border-color: var(--accent-strong);
  box-shadow: 0 8px 18px -6px rgba(79, 70, 229, .65);
}
button.secondary, .button.secondary {
  background: linear-gradient(180deg, #ffffff, var(--accent-soft));
  color: var(--accent-strong); border-color: #c7d2fe;
}
button.secondary:hover, .button.secondary:hover { background: #e0e7ff; border-color: #a5b4fc; }
button.danger, .button.danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
button.danger:hover, .button.danger:hover { background: #fee2e2; }
.button.ghost, button.ghost { background: transparent; border-color: var(--line-strong); color: var(--muted); box-shadow: none; }
.button.ghost:hover { background: var(--bg-deep); color: var(--fg); }
button.big, .button.big { padding: .68rem 1.2rem; font-size: 1rem; border-radius: 10px; }
button.small, .button.small { padding: .3rem .6rem; font-size: .82rem; }
.button.block { width: 100%; justify-content: center; }
.button.active {
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  color: #fff; border-color: var(--accent);
}

.action-row { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.actions { white-space: nowrap; }
.actions form.inline { display: inline-block; margin: 0 .15rem; }
.view-switch { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }

/* ------------------------------------------------------------- import commit bar */

.commit-form { margin: 0; }
.commit-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: .75rem 1.1rem; align-items: flex-end;
  justify-content: space-between;
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .95rem; margin-bottom: .8rem;
  box-shadow: var(--shadow);
}
.commit-fields { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-end; }
.commit-actions { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.inline-hint { margin-top: .55rem; }
kbd {
  background: linear-gradient(180deg, #ffffff, var(--bg-deep));
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 6px; padding: .03rem .4rem; font-size: .8em; font-family: ui-monospace, monospace;
}

/* ------------------------------------------------------------- pagination / auth */

.pager {
  display: flex; gap: 1rem; align-items: center; margin-top: .8rem;
  padding: .55rem .8rem; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs);
}
.pager span { color: var(--muted); font-size: .9rem; }
.pager a { font-weight: 600; }

.auth-card {
  width: 100%; max-width: 30rem; margin: 3rem auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 1.5rem 1.7rem; box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.auth-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent-violet), var(--ok-2));
}
.auth-card h1 { margin-top: .2rem; }
.auth-card p { display: flex; flex-direction: column; gap: .3rem; margin: .65rem 0; }

/* ------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 1.4rem; z-index: 60;
  padding: .7rem 1.05rem; border-radius: 10px; font-weight: 600;
  background: linear-gradient(140deg, #0f172a, #1e293b); color: #fff;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0; transform: translate(-50%, 10px);
  transition: opacity .22s var(--ease), transform .22s var(--ease);
  max-width: min(30rem, 90vw);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { background: linear-gradient(140deg, var(--ok-2), var(--ok)); }
.toast-error { background: linear-gradient(140deg, #f87171, var(--danger)); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 860px) {
  .scroll, .table-scroll, .preview-scroll { max-height: calc(100vh - 210px); }
  .commit-bar { position: static; }
  .container { padding: .8rem .8rem 1.3rem; }
  .topbar-inner { padding: .6rem .8rem; }
  h1 { font-size: 1.28rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .topbar, .footer, .toolbar, .pager, .toast, .actions { display: none !important; }
  body { background: #fff; }
  .scroll { max-height: none; overflow: visible; }
}
