:root {
  --c-bg: #eef3f8;
  --c-surface: #ffffff;
  --c-border: #ccd9e7;
  --c-text: #102033;
  --c-muted: #4f647b;
  --c-primary: #0f4c81;
  --c-primary-h: #0b3b63;
  --c-danger: #c33d2b;
  --c-warning: #a05d12;
  --c-success: #1d7f49;
  --c-draft: #6b7280;
  --c-submitted: #0f4c81;
  --c-approved: #1d7f49;
  --c-exporting: #a05d12;
  --c-rejected: #c33d2b;
  --c-exported-to-lexflow: #0f766e;
  --c-export-failed: #c33d2b;
  --radius: 8px;
  --shadow: 0 6px 20px rgba(13, 42, 74, .08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Trebuchet MS", Tahoma, Arial, sans-serif;
  font-size: .9375rem;
  background: linear-gradient(180deg, #f4f8fc 0%, #edf3f9 100%);
  color: var(--c-text);
  line-height: 1.5;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: .55rem 1.1rem;
  background: linear-gradient(180deg, #ffffff 0%, #f6f9fd 100%);
  border-bottom: 1px solid var(--c-border);
  flex-wrap: nowrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  text-decoration: none;
  color: #27486b;
  font-weight: 600;
  font-size: .9rem;
  flex: 0 0 auto;
}
.brand-logo {
  height: 28px;
  width: auto;
}
.nav-links { display: flex; gap: .9rem; align-items: center; font-size: .875rem; }
.nav-links a {
  color: var(--c-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .35rem;
  border-radius: 6px;
}
.nav-links a:hover { background: #e6eff9; }
.nav-icon { width: 15px; height: 15px; object-fit: contain; }

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}
.global-sidebar {
  border-right: 1px solid var(--c-border);
  background: #fbfdff;
  padding: 1rem .85rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.global-sidebar-brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding-bottom: .65rem;
  border-bottom: 1px solid #d4e0eb;
}
.global-brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.global-brand-title {
  font-weight: 700;
  color: #183a59;
}
.global-brand-sub {
  font-size: .74rem;
  color: var(--c-muted);
}
.global-sidebar-section-title {
  font-size: .73rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #4a6684;
}
.global-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.global-sidebar-link {
  display: flex;
  align-items: center;
  gap: .45rem;
  text-decoration: none;
  color: #173c5c;
  border: 1px solid #d7e4f1;
  background: #f7fbff;
  border-radius: 8px;
  padding: .58rem .62rem;
  font-weight: 600;
}
.global-sidebar-link:hover {
  background: #eaf3fc;
}
.global-user-card {
  margin-top: auto;
  border: 1px solid var(--c-border);
  border-radius: 9px;
  background: #f7fbff;
  padding: .65rem;
  color: var(--c-muted);
  font-size: .78rem;
  line-height: 1.45;
}
.global-user-card strong {
  display: block;
  color: var(--c-text);
  margin-bottom: .2rem;
}
.app-workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-logo-cabinet {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
}

.sidebar-logo-cabinet img {
  max-width: 264px;
  width: 100%;
  height: auto;
  object-fit: contain;
  opacity: 0.95;
}

.main { max-width: 1120px; margin: 0 auto; padding: 1.4rem 1rem; }
.main.main-app {
  max-width: none;
  margin: 0;
  width: 100%;
  padding: 1rem 1.2rem;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
  gap: .6rem;
}
.page-header h2 { font-size: 1.22rem; font-weight: 700; color: #15314f; }

.body-centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 10%, #f9fcff 0%, #edf3fa 55%, #e6eef8 100%);
}
.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.login-logo { display: block; width: 120px; margin: 0 auto .5rem; }
.login-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 1.4rem; text-align: center; }
.login-title span { color: var(--c-primary); }

.form-stack { display: flex; flex-direction: column; gap: 1rem; }
.form-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: .3rem; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }
.field-check { display: flex; align-items: center; gap: .5rem; }
.field-readonly {
  display: flex;
  gap: 1.2rem;
  padding: .75rem;
  background: #f3f8fe;
  border: 1px solid #dce9f8;
  border-radius: var(--radius);
  font-size: .875rem;
  flex-wrap: wrap;
}
.form-actions { display: flex; gap: .75rem; margin-top: .5rem; flex-wrap: wrap; }
label { font-size: .875rem; font-weight: 600; color: #1b395a; }
.required { color: var(--c-danger); }
input[type=text], input[type=date], input[type=number], input[type=email],
input[type=password], textarea, select {
  width: 100%;
  padding: .52rem .72rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .9375rem;
  font-family: inherit;
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #7ea7d2;
  box-shadow: 0 0 0 2px rgba(15, 76, 129, .12);
}
.input-sm { padding: .35rem .6rem; font-size: .875rem; }
.hint { font-size: .8125rem; color: var(--c-muted); }
.hint-block {
  display: block;
  font-size: .8125rem;
  color: var(--c-muted);
  padding: .5rem 0;
  line-height: 1.4;
}
.form-inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }
.mb-1 { margin-bottom: 1rem; }
.section-gap-top { margin-top: 1.25rem; }
.breadcrumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  align-items: center;
}
.documents-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1.05rem;
  align-items: start;
}
.docs-tree-column {
  align-self: start;
}
.docs-sidebar-title {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #355477;
  margin-bottom: .35rem;
}
.docs-tree-column {
  background: #fbfdff;
  border-color: #cedceb;
  box-shadow: none;
}
.docs-tree-header {
  margin-bottom: .5rem;
}
.docs-tree-card {
  background: var(--c-surface);
  border: 1px solid #d3dfec;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px #eef4fb;
  padding: .5rem .45rem;
  min-height: 24rem;
}
.explorer-group {
  margin-top: .55rem;
}
.explorer-tree-list {
  list-style: none;
  margin: 0;
  padding-left: .85rem;
}
.explorer-tree-list .explorer-tree-list {
  border-left: 1px solid #d8e4f0;
  margin-left: .28rem;
  padding-left: .65rem;
}
.explorer-tree-node {
  margin: .08rem 0;
}
.explorer-tree-link.is-branch {
  background: #f3f8fe;
  border-left-color: #b6cce3;
}
.explorer-group-label {
  font-size: .72rem;
  color: #5f7994;
  margin-bottom: .18rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.explorer-link {
  display: block;
  text-decoration: none;
  color: #1b4467;
  border-radius: 9px;
  border-left: 3px solid transparent;
  padding: .42rem .52rem;
  margin-bottom: .14rem;
  font-size: .865rem;
  position: relative;
}
.explorer-root {
  font-weight: 700;
}
.explorer-indent-1 {
  margin-left: .52rem;
  padding-left: .72rem;
}
.explorer-indent-2 {
  margin-left: 1.02rem;
  padding-left: .8rem;
}
.explorer-indent-1::before,
.explorer-indent-2::before {
  content: "";
  position: absolute;
  left: .28rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #d8e4f0;
}
.explorer-link:hover,
.explorer-link:focus-visible {
  background: #f1f7fd;
  border-left-color: #87acd2;
}
.explorer-link.is-active {
  background: #dbeaf9;
  border-left-color: #0f4c81;
  color: #0c3d66;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px #bfd6ee;
}
.docs-main-column {
  min-width: 0;
}
.docs-main-header h2 {
  margin: 0;
  font-size: 1.34rem;
  color: #132f4b;
}
.docs-main-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: .56rem;
}
.docs-toolbar {
  display: inline-flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.docs-breadcrumb-row {
  font-size: .79rem;
  color: #5a748f;
}
.docs-breadcrumb-row a {
  color: #2a5a89;
  text-decoration: none;
}
.docs-breadcrumb-row a:hover {
  text-decoration: underline;
}
.docs-panel-header {
  box-shadow: none;
  border-color: #cddceb;
}
.docs-target-card {
  background: linear-gradient(180deg, #f7fbff 0%, #ffffff 100%);
  border-color: #d1deeb;
  box-shadow: none;
}
.docs-target-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: #456482;
  margin-bottom: .25rem;
}
.docs-target-path code {
  font-size: .83rem;
}
.docs-subtitle {
  margin-bottom: .55rem;
  font-weight: 700;
  color: #234667;
}
.docs-documents-panel {
  padding-top: .9rem;
  border-color: #ccdcec;
  box-shadow: none;
}
.docs-panel-context {
  border-left: 4px solid #86add4;
}
.docs-panel-action {
  box-shadow: none;
  border-color: #d4dfec;
}
.docs-main-column .alert-info {
  border-color: #c9dbee;
  background: #f2f8ff;
  color: #1f476f;
}
.docs-documents-panel .table {
  box-shadow: none;
  border: 1px solid #d3dfeb;
}
.docs-documents-panel .table th {
  background: #eaf3fd;
  color: #23486d;
}
.docs-documents-panel .table td:first-child {
  font-weight: 600;
  color: #153754;
}
.docs-documents-panel .cell-actions {
  justify-content: flex-start;
  gap: .32rem;
}
.rename-form {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  width: 100%;
  max-width: 520px;
}
.rename-input {
  max-width: 320px;
}
.rename-label {
  display: inline-block;
}
.is-hidden {
  display: none !important;
}
.timesheet-row-other td {
  background: #f5f7fa;
  color: #6b7280;
}
.timesheet-inline-form {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.timesheet-inline-form input[type="date"] {
  width: 150px;
}
.timesheet-inline-form input[type="text"] {
  width: 260px;
}
.timesheet-inline-form input[type="number"] {
  width: 90px;
}
.table-sort-link {
  color: inherit;
  text-decoration: none;
}
.table-sort-link:hover {
  text-decoration: underline;
}
.sort-indicator {
  font-size: .72rem;
  color: #335a84;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: .45rem .9rem;
  border: 1px solid #c7d8ea;
  border-radius: var(--radius);
  background: #f7fbff;
  color: #193652;
  font-size: .875rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: #e9f2fb; border-color: #aec5de; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-h); border-color: var(--c-primary-h); }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-warning { background: var(--c-warning); border-color: var(--c-warning); color: #fff; }
.btn-validate-soft {
  background: #d8f2e4;
  border-color: #8ecfa8;
  color: #1f6a3e;
}
.btn-validate-soft:hover {
  background: #c2ebd4;
  border-color: #74bd92;
}
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: .3rem .65rem; font-size: .8125rem; }
.btn-link {
  background: none;
  border: none;
  color: var(--c-primary);
  cursor: pointer;
  font-size: .875rem;
  padding: 0;
  text-decoration: underline;
  font-family: inherit;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  background: var(--c-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th {
  background: #ecf3fb;
  padding: .62rem .85rem;
  text-align: left;
  font-weight: 700;
  font-size: .8125rem;
  border-bottom: 1px solid var(--c-border);
  color: #27486b;
}
.table td { padding: .62rem .85rem; border-bottom: 1px solid var(--c-border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f7fbff; }
.cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-desc { max-width: 260px; }
.cell-case { font-family: ui-monospace, monospace; font-size: .85rem; white-space: nowrap; }
.cell-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-draft            { background: #edf1f5; color: var(--c-draft); }
.badge-submitted        { background: #dbe9f7; color: var(--c-submitted); }
.badge-approved         { background: #d8f2e4; color: var(--c-approved); }
.badge-exporting        { background: #f6e7cf; color: var(--c-exporting); }
.badge-rejected         { background: #f8dddd; color: var(--c-rejected); }
.badge-exported-to-lexflow { background: #d9f3ee; color: var(--c-exported-to-lexflow); }
.badge-export-failed    { background: #f8dddd; color: var(--c-export-failed); }
.badge-admin            { background: #dde9f8; color: #17406d; }
.badge-lexflow-import   { background: #e8eef5; color: #294861; margin-left: .35rem; }
.badge-vps-exported     { background: #e2f1ea; color: #1d5b42; margin-left: .35rem; }
.tag {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 4px;
  background: #f3f8fe;
  font-size: .8125rem;
  border: 1px solid #d8e6f4;
}

.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .875rem;
  border: 1px solid transparent;
}
.alert-error { background: #f9e0de; color: #7d2116; border-color: #e7b4ad; }
.alert-success { background: #e0f4e8; color: #165330; border-color: #b4ddc4; }
.alert-info { background: #eaf3ff; color: #0f3f6e; border-color: #b9d2f1; }

.timesheet-row-import td {
  background: #f5f8fb;
}
.timesheet-row-exported td {
  background: #f2f8f4;
}

.review-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .75rem;
  box-shadow: var(--shadow);
}
.review-header { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; font-size: .875rem; }
.review-body { font-size: .9rem; margin-bottom: .75rem; }
.review-body p { margin-bottom: .4rem; }
.review-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.notes-internal { font-size: .8125rem; color: var(--c-muted); margin-top: .4rem; }

.admin-tabs { display: flex; gap: .5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab-link {
  padding: .4rem .9rem;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  text-decoration: none;
  font-size: .875rem;
  background: var(--c-surface);
}
.tab-link:hover { background: #eef4fb; }

.empty-state {
  padding: 2.5rem;
  text-align: center;
  color: var(--c-muted);
  background: var(--c-surface);
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
}
.text-muted { color: var(--c-muted); }
code {
  font-family: ui-monospace, monospace;
  font-size: .85em;
  background: #edf4fb;
  padding: .1em .35em;
  border-radius: 3px;
}

@media (max-width: 980px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .global-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--c-border);
  }
}

@media (max-width: 700px) {
  .field-row { flex-direction: column; }
  .table { font-size: .8125rem; }
  .cell-desc { max-width: 140px; }
  .brand-logo { height: 24px; }
  .documents-shell { grid-template-columns: 1fr; }
  .docs-tree-column,
  .docs-main-column { min-height: auto; }
}
