:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #d8dee8;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #ccfbf1;
  --accent: #2563eb;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.09);
  --shadow-strong: 0 24px 80px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(226, 232, 240, 0.72), rgba(246, 248, 251, 0) 320px),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  letter-spacing: 0;
  font-size: 14px;
}

body.menu-open {
  overflow: hidden;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(10px);
}

.login-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: auto;
  isolation: isolate;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
  display: grid;
  gap: 16px;
  overflow: hidden;
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 88px;
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.16), rgba(45, 212, 191, 0));
  pointer-events: none;
}

body.authenticated .login-gate {
  display: none !important;
}

body:not(.authenticated) .app-shell {
  filter: blur(10px);
  opacity: 0.72;
  pointer-events: none;
  user-select: none;
}

body:not(.authenticated) {
  overflow: hidden;
}

.login-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.login-brand h1 {
  margin: 0;
  font-size: 28px;
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
}

.login-form {
  position: relative;
  display: grid;
  gap: 12px;
}

.login-field {
  display: grid;
  gap: 6px;
  width: 100%;
}

.login-field span {
  font-size: 12px;
  color: var(--muted);
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.login-build-info {
  position: relative;
  display: grid;
  gap: 4px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 228px 1fr;
  transition: grid-template-columns 240ms ease;
}

.app-shell.menu-collapsed {
  grid-template-columns: 0 1fr;
}

.app-shell.menu-collapsed .sidebar {
  transform: translateX(110%);
  opacity: 0;
  pointer-events: none;
  padding-left: 0;
  padding-right: 0;
}

.app-shell.grid-fullscreen {
  grid-template-columns: 1fr;
}

.app-shell.grid-fullscreen .sidebar,
.app-shell.grid-fullscreen .form-panel {
  display: none;
}

.app-shell.grid-fullscreen .main {
  padding: 12px;
}

.app-shell.grid-fullscreen .content-grid {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.grid-fullscreen .table-panel {
  min-height: calc(100vh - 132px);
}

.app-shell.grid-fullscreen .table-wrap {
  max-height: calc(100vh - 286px);
}

.app-shell.form-collapsed .content-grid {
  grid-template-columns: minmax(0, 1fr) 0;
}

.app-shell.form-collapsed .form-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(110%);
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  overflow: hidden;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(20, 184, 166, 0.16), rgba(15, 23, 42, 0) 260px),
    #102a43;
  color: #eef6ff;
  padding: 18px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(203, 213, 225, 0.48) transparent;
  transition: transform 240ms ease, opacity 200ms ease, padding 240ms ease, box-shadow 240ms ease;
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.06);
}

.sidebar::-webkit-scrollbar,
.tab-list::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.sidebar::-webkit-scrollbar-thumb,
.tab-list::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.42);
  background-clip: padding-box;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.sidebar-close,
.mobile-menu-backdrop {
  display: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  position: relative;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(145deg, #7dd3fc, #2dd4bf 68%, #0f766e);
  color: #ffffff;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(45, 212, 191, 0.24);
  overflow: hidden;
}

.logo-cloud {
  position: absolute;
  inset: 9px 7px 12px;
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 999px 999px 11px 11px;
  border-bottom-width: 2px;
  opacity: 0.88;
}

.logo-cloud::before,
.logo-cloud::after {
  content: "";
  position: absolute;
  bottom: 8px;
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  background: transparent;
}

.logo-cloud::before {
  width: 12px;
  height: 12px;
  right: -3px;
}

.logo-cloud::after {
  width: 11px;
  height: 11px;
  left: -2px;
}

.logo-core {
  position: relative;
  z-index: 1;
  transform: translateY(1px);
  text-shadow: 0 2px 8px rgba(8, 47, 73, 0.24);
}

.logo-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #ffffff;
  left: 8px;
  top: 8px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.16);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.brand p,
.eyebrow,
.form-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.sidebar .brand p {
  color: #b9cbe0;
}

.system-menu {
  display: grid;
  gap: 6px;
}

.menu-btn {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #eff6ff;
  border-radius: 8px;
  padding: 10px 11px;
  text-align: right;
  cursor: pointer;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  align-items: center;
  transform: translateZ(0);
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateX(-2px);
}

.menu-icon,
.btn-icon,
.sort-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.menu-icon svg,
.btn-icon svg,
.sort-icon svg {
  width: 16px;
  height: 16px;
}

.menu-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.11);
  color: #99f6e4;
}

.menu-copy {
  min-width: 0;
}

.menu-btn strong {
  display: block;
  font-size: 12px;
  line-height: 1.35;
}

.menu-btn span {
  display: block;
  margin-top: 4px;
  color: #b9cbe0;
  font-size: 10px;
  line-height: 1.45;
}

.menu-btn.active {
  background: #e0f2fe;
  color: #082f49;
  border-color: rgba(14, 165, 233, 0.5);
  box-shadow: 0 14px 32px rgba(8, 47, 73, 0.22);
}

.menu-btn.active .menu-icon {
  background: white;
  color: var(--brand);
}

.menu-btn.active span {
  color: #0369a1;
}

.main {
  min-width: 0;
  padding: 14px;
  width: min(100%, 1680px);
  margin: 0 auto;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px 16px;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 8px 0;
  backdrop-filter: blur(14px);
}

.topbar h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  max-height: calc(1.25em * 2);
  overflow: hidden;
}

.top-actions,
.toolbar,
.module-tabs,
.meta-row,
.form-header,
.form-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions {
  display: grid;
  grid-template-columns: repeat(5, auto);
  justify-content: end;
  align-content: start;
  row-gap: 8px;
}

.module-tabs {
  display: grid;
  gap: 8px;
  overflow-x: hidden;
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.accounting-design {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
  align-items: stretch;
  margin: 0 0 12px;
  padding: 8px;
  border: 1px solid #aeb7c5;
  border-radius: 4px;
  background:
    linear-gradient(180deg, #eef2f7, #cfd6e2 48%, #b9c2d0 49%, #eef2f7),
    #d8dee8;
  box-shadow: inset 0 1px 0 #ffffff, 0 10px 26px rgba(15, 23, 42, 0.08);
}

.accounting-design[hidden] {
  display: none !important;
}

.accounting-design-copy {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 76px;
  padding: 10px 12px;
  border: 1px solid #b5bfcc;
  border-radius: 3px;
  background: linear-gradient(180deg, #f8fafc, #dfe5ee);
  color: #1f2937;
}

.accounting-design-copy span {
  color: #64748b;
  font-size: 11px;
}

.accounting-design-copy strong {
  font-size: 13px;
  line-height: 1.7;
}

.accounting-design-shots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.accounting-design-shots img {
  width: 100%;
  height: 76px;
  object-fit: cover;
  object-position: top right;
  border: 1px solid #9aa7b8;
  border-radius: 3px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 #ffffff;
}

.tab-section {
  min-width: 0;
}

.tab-section-title {
  color: var(--muted);
  font-size: 11px;
  padding: 0 2px 6px;
}

.tab-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  mask-image: linear-gradient(90deg, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%);
}

.tab-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.tab-btn:hover {
  border-color: #94a3b8;
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.09);
}

.tab-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
  box-shadow: 0 16px 34px rgba(15, 118, 110, 0.22);
}

.accounting-mode {
  --bg: #d9dee7;
  --surface: #f4f6f9;
  --surface-soft: #e5eaf1;
  --text: #1f2937;
  --muted: #566276;
  --line: #b8c1cd;
  --brand: #f59e0b;
  --brand-dark: #d97706;
  --brand-soft: #fff7ed;
  --accent: #2563eb;
  --shadow: 0 8px 22px rgba(30, 41, 59, 0.12);
  --shadow-strong: 0 12px 32px rgba(30, 41, 59, 0.18);
}

.accounting-mode .sidebar {
  background: linear-gradient(180deg, #f2f5f9, #c7cfdb);
  color: #1f2937;
  border-left: 1px solid #8f9aaa;
  box-shadow: inset 1px 0 0 #ffffff;
}

.accounting-mode .sidebar .brand p,
.accounting-mode .menu-btn span {
  color: #596579;
}

.accounting-mode .brand-mark,
.accounting-mode .menu-icon {
  background: linear-gradient(145deg, #ffe08a, #f59e0b 64%, #d97706);
  color: #ffffff;
  box-shadow: none;
}

.accounting-mode .menu-btn {
  min-height: 40px;
  border-color: #aeb7c5;
  border-radius: 2px;
  background: linear-gradient(180deg, #f7f9fc, #d7dee8);
  color: #263243;
  box-shadow: inset 0 1px 0 #ffffff;
}

.accounting-mode .menu-btn:hover {
  border-color: #8f9aaa;
  background: linear-gradient(180deg, #ffffff, #dfe5ee);
  transform: none;
}

.accounting-mode .menu-btn.active {
  border-color: #e0a221;
  background: linear-gradient(180deg, #ffd87a, #f59e0b);
  color: #111827;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.accounting-mode .menu-btn.active span {
  color: #4b3a11;
}

.accounting-mode .topbar {
  margin-bottom: 8px;
  padding: 7px 10px;
  border: 1px solid #aeb7c5;
  border-radius: 3px;
  background: linear-gradient(180deg, #f7f9fc, #cfd6e2);
  box-shadow: inset 0 1px 0 #ffffff;
}

.accounting-mode .module-tabs {
  gap: 4px;
  margin-bottom: 8px;
  padding: 6px 6px 0;
  border: 1px solid #aeb7c5;
  border-radius: 3px;
  background: linear-gradient(180deg, #e8edf4, #cbd3df);
}

.accounting-mode .tab-section-title {
  padding: 0 2px 4px;
  color: #475569;
}

.accounting-mode .tab-list {
  gap: 2px;
  padding-bottom: 6px;
}

.accounting-mode .tab-btn {
  border-color: #9ca8b8;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, #f9fafb, #d6dde8);
  box-shadow: inset 0 1px 0 #ffffff;
  padding: 7px 12px;
}

.accounting-mode .tab-btn.active {
  border-color: #6b7280;
  background: linear-gradient(180deg, #ffffff, #f1f5f9);
  color: #111827;
  box-shadow: inset 0 3px 0 #f59e0b;
}

.accounting-mode .panel,
.accounting-mode .table-wrap {
  border-radius: 3px;
  box-shadow: inset 0 1px 0 #ffffff, var(--shadow);
}

.accounting-mode .table-panel,
.accounting-mode .form-panel {
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
}

.accounting-mode .toolbar {
  padding: 8px;
  border: 1px solid #b8c1cd;
  border-radius: 3px;
  background: linear-gradient(180deg, #eef2f7, #d6dde8);
}

.accounting-mode input,
.accounting-mode select,
.accounting-mode textarea,
.accounting-mode .ghost-btn,
.accounting-mode .secondary-btn,
.accounting-mode .row-btn {
  border-radius: 2px;
  background: linear-gradient(180deg, #ffffff, #edf1f6);
}

.accounting-mode .primary-btn {
  border-radius: 2px;
  background: linear-gradient(180deg, #ffc95a, #f59e0b);
  color: #111827;
}

.accounting-mode th {
  background: linear-gradient(180deg, #eef2f7, #cfd6e2);
  color: #1f2937;
}

.accounting-mode td {
  background: #ffffff;
}

.accounting-mode tr:hover td {
  background: #fff8e8;
}

.accounting-mode tbody tr.is-active td {
  background: #fff1c2;
}

.accounting-mode tbody tr.is-active {
  box-shadow: inset 3px 0 0 #f59e0b;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

.panel:hover {
  box-shadow: var(--shadow-strong);
}

.table-panel {
  min-width: 0;
  padding: 12px;
}

.form-panel {
  position: sticky;
  top: 24px;
  padding: 12px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  transition: transform 220ms ease, opacity 180ms ease, padding 220ms ease, border-color 180ms ease;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.8fr) repeat(4, minmax(132px, 0.88fr)) auto auto;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.search-box,
.filter-box,
.field {
  display: grid;
  gap: 4px;
}

.search-box {
  min-width: 220px;
  flex: 1;
}

.filter-box {
  min-width: 148px;
}

.compact-filter {
  min-width: 116px;
}

.goto-filter {
  min-width: 168px;
}

label {
  font-size: 11px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  background: white;
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input[type="number"] {
  appearance: textfield;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

textarea {
  min-height: 76px;
  resize: vertical;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.row-btn,
.secondary-btn {
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
  font-size: 11px;
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.row-btn:hover,
.secondary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.1);
}

.primary-btn:active,
.ghost-btn:active,
.danger-btn:active,
.row-btn:active,
.secondary-btn:active {
  transform: translateY(0);
}

.primary-btn {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: white;
}

.primary-btn:hover {
  background: var(--brand-dark);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.ghost-btn:hover {
  border-color: #94a3b8;
}

.secondary-btn {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: #334155;
  padding: 8px 10px;
  min-height: 34px;
}

.secondary-btn:disabled {
  opacity: 0.46;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.danger-btn {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.file-action input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.meta-row {
  justify-content: space-between;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11px;
  padding: 10px 2px 8px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: calc(100vh - 252px);
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.08), transparent 18px) right / 28px 100% no-repeat,
    linear-gradient(270deg, rgba(15, 23, 42, 0.08), transparent 18px) left / 28px 100% no-repeat,
    white;
  scroll-behavior: smooth;
  outline: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: right;
  vertical-align: top;
  font-size: 11px;
  line-height: 1.55;
}

th {
  background: var(--surface-soft);
  color: #334155;
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: inset 0 -1px 0 var(--line);
}

th.sortable {
  cursor: pointer;
}

th[data-sort]::after {
  content: attr(data-sort);
  color: var(--brand);
  font-weight: 800;
  margin-right: 6px;
}

tr:hover td {
  background: #f8fbfd;
}

tbody tr {
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease;
}

tbody tr.is-active td {
  background: #e8fffa;
}

tbody tr.is-active {
  box-shadow: inset 3px 0 0 var(--brand);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
  white-space: nowrap;
}

.row-btn {
  border: 1px solid var(--line);
  background: white;
  padding: 6px 8px;
  font-size: 11px;
}

.row-btn.delete {
  color: var(--danger);
  border-color: #fecaca;
  background: #fff6f7;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 42px 16px;
}

.form-header {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.form-header h3 {
  margin: 2px 0 0;
  font-size: 15px;
  line-height: 1.35;
}

.editor-form {
  display: grid;
  gap: 8px;
}

.form-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
}

.form-field {
  display: grid;
  gap: 5px;
}

.form-header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.inline-input .secondary-btn {
  min-width: 58px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #ecfdf5;
  color: #047857;
  font-size: 12px;
}

.badge.off {
  background: #f1f5f9;
  color: #64748b;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-shell.menu-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(94vw, 390px);
    max-height: none;
    z-index: 10;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    box-shadow: -22px 0 70px rgba(15, 23, 42, 0.25);
  }

  .app-shell.menu-collapsed .sidebar {
    display: block;
    transform: translateX(110%);
    opacity: 0;
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9;
    display: none;
    border: 0;
    padding: 0;
    background: rgba(15, 23, 42, 0.36);
    animation: fadeIn 180ms ease both;
  }

  .app-shell:not(.menu-collapsed) .mobile-menu-backdrop {
    display: block;
  }

  .sidebar-close {
    margin-right: auto;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.08);
    color: #e0f2fe;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
  }

  .sidebar .brand {
    position: sticky;
    top: -1px;
    z-index: 2;
    margin: -16px -12px 12px;
    padding: 16px 12px 12px;
    background: linear-gradient(180deg, #102a43 78%, rgba(16, 42, 67, 0));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .form-panel {
    position: static;
  }

  .app-shell.form-collapsed .content-grid {
    grid-template-columns: 1fr;
  }

  .app-shell.form-collapsed .form-panel {
    display: none;
  }
}

@media (max-width: 720px) {
  body {
    overflow-x: hidden;
  }

  .sidebar {
    padding: 16px 12px;
  }

  .brand {
    margin-bottom: 14px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .system-menu {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .menu-btn {
    padding: 9px 10px;
    grid-template-columns: 32px 1fr;
  }

  .menu-btn strong {
    font-size: 12px;
  }

  .menu-btn span {
    font-size: 10px;
  }

  .main {
    padding: 12px;
  }

  .login-gate {
    padding: 14px;
  }

  .login-panel {
    padding: 18px;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 10px;
  }

  .topbar h2 {
    font-size: 17px;
  }

  .top-actions,
  .toolbar,
  .meta-row,
  .form-header,
  .form-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .inline-input {
    grid-template-columns: 1fr auto;
  }

  .search-box,
  .filter-box,
  .file-action {
    width: 100%;
  }

  .module-tabs {
    margin-left: -12px;
    margin-right: -12px;
    padding: 0 12px 8px;
  }

  .tab-list {
    gap: 6px;
  }

  .tab-btn {
    padding: 9px 12px;
    font-size: 12px;
  }

  .table-panel,
  .form-panel {
    padding: 12px;
  }

  .table-wrap {
    max-height: calc(100vh - 340px);
  }

  .table-wrap {
    max-height: 58vh;
    border-radius: 6px;
  }

  table {
    min-width: 760px;
  }

  th,
  td {
    padding: 8px 9px;
    font-size: 11px;
  }

  .app-shell.grid-fullscreen .main {
    padding: 8px;
  }

  .app-shell.grid-fullscreen .table-panel {
    min-height: calc(100vh - 74px);
  }

  .app-shell.grid-fullscreen .table-wrap {
    max-height: calc(100vh - 218px);
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 100vw;
  }

  .top-actions {
    grid-template-columns: 1fr;
  }

  .brand p,
  .eyebrow,
  .form-header p {
    font-size: 11px;
  }

  .meta-row {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
