:root {
  --ink: #17202a;
  --muted: #64707d;
  --line: #d8dee6;
  --panel: #fff;
  --page: #f5f7fa;
  --brand: #116466;
  --brand-strong: #0b4f50;
  --accent: #c7502c;
  --ok: #247a4d;
  --warn: #b26b00;
  --bad: #b33a3a;
  --shadow: 0 18px 50px rgba(21, 38, 53, 0.12);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.is-hidden { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.loading-screen { position: fixed; inset: 0; z-index: 1000; min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #0f242a; color: #fff; }
.loading-card { width: min(360px, 100%); display: grid; justify-items: center; gap: 18px; padding: 32px 28px; background: #0f242a; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; box-shadow: 0 18px 50px rgba(0,0,0,.22); text-align: center; }
.loading-card strong { font-size: 22px; letter-spacing: 0; }
.loading-card strong::after { content: ""; display: inline-block; width: 1.4em; text-align: left; animation: loadingDots 1.15s steps(4, end) infinite; }
.loading-mark { position: relative; width: 82px; height: 82px; display: grid; place-items: center; }
.loading-mark::before { content: ""; width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.22); border-top-color: #f2c94c; border-radius: 50%; animation: loadingSpin .9s linear infinite; }
.loading-mark span { position: absolute; width: 14px; height: 14px; border-radius: 4px; background: #f2c94c; animation: loadingPulse 1.2s ease-in-out infinite; }
.loading-mark span:nth-child(1) { top: 0; left: 34px; animation-delay: 0s; }
.loading-mark span:nth-child(2) { right: 0; top: 34px; animation-delay: .15s; }
.loading-mark span:nth-child(3) { bottom: 0; left: 34px; animation-delay: .3s; }
.loading-mark span:nth-child(4) { left: 0; top: 34px; animation-delay: .45s; }
.loading-line { width: min(260px, 100%); height: 6px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.16); }
.loading-line span { display: block; width: 42%; height: 100%; border-radius: inherit; background: #f2c94c; animation: loadingSlide 1.05s ease-in-out infinite; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #0f242a; }
.login-card { width: min(420px, 100%); background: #fff; border-radius: 8px; padding: 24px; display: grid; gap: 16px; box-shadow: var(--shadow); overflow: hidden; }
.login-card label { display: grid; gap: 8px; color: var(--muted); font-weight: 700; min-width: 0; }
.login-card input, .login-card select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; }
.login-card .primary-button { width: 100%; }
.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #0f242a; color: #eef7f8; padding: 24px 18px; display: flex; flex-direction: column; gap: 24px; }
.brand-logo { display: block; height: auto; object-fit: contain; }
.brand-logo-login { width: min(320px, 100%); margin: 0 auto 4px; }
.sidebar-brand { display: grid; gap: 10px; }
.topbar-logo-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; box-shadow: 0 8px 24px rgba(21,38,53,.06); }
.brand-logo-topbar { width: min(520px, 100%); max-height: 120px; border-radius: 8px; }
.sidebar-brand span, .sidebar-note { color: #aac3c8; font-size: 13px; }
.nav { display: grid; gap: 8px; }
.nav-item { border: 0; border-radius: 8px; background: transparent; color: inherit; display: flex; align-items: center; gap: 10px; padding: 12px; text-align: left; }
.nav-item:hover, .nav-item.is-active { background: rgba(255,255,255,.1); }
.nav-icon { width: 24px; height: 24px; border: 1px solid rgba(255,255,255,.22); border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 24px; color: #c9fbff; background: rgba(255,255,255,.08); font-size: 14px; line-height: 1; }
.nav-item.is-active .nav-icon { color: #0f242a; background: #f2c94c; border-color: transparent; }
.sidebar-note { margin-top: auto; display: grid; gap: 10px; padding: 14px; border: 1px solid rgba(255,255,255,.16); border-radius: 8px; }
.main { padding: 28px; overflow: auto; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0; color: var(--brand); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.topbar-actions, .dialog-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.primary-button, .ghost-button, .danger-button, .link-button, .icon-button { border: 1px solid transparent; border-radius: 8px; min-height: 40px; padding: 0 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; line-height: 1; text-decoration: none; }
.primary-button { background: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-strong); }
button:disabled, .file-chip:has(input:disabled) { cursor: not-allowed; opacity: .58; }
.ghost-button { background: #fff; border-color: var(--line); color: var(--ink); }
.danger-button { background: #fff0f0; color: var(--bad); border-color: #f0cccc; }
.link-button { background: transparent; color: #fff; border-color: rgba(255,255,255,.2); padding: 0 10px; }
.icon-button { width: 36px; min-height: 36px; padding: 0; background: #f0f3f6; color: var(--ink); }
.view { display: none; }
.view.is-visible { display: block; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(170px,1fr)); gap: 14px; margin-bottom: 18px; }
.metric, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(21,38,53,.06); }
.metric { padding: 16px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 8px; font-size: 30px; }
.work-grid { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(320px,.75fr); gap: 18px; }
.report-filter-panel { margin-bottom: 18px; }
.report-period-controls { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.report-period-controls label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; min-width: 180px; }
.report-period-controls input, .report-period-controls select { min-height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; color: var(--ink); background: #fff; }
.report-sections { display: grid; gap: 18px; margin-top: 18px; }
.report-table-panel { overflow: hidden; }
.print-report-period { display: none; }
.report-table-wrap { overflow-x: auto; }
.report-table-wrap table { min-width: 760px; }
.panel { padding: 18px; }
.panel-header, .section-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; }
.panel h2, .section-title h3, .dialog-header h2 { margin: 4px 0 0; font-size: 20px; }
.contract-dialog .section-title h3 { font-size: 13px; line-height: 1.3; }
.timeline, .status-bars, .type-bars, .report-list { display: grid; gap: 12px; }
.timeline-item { display: grid; grid-template-columns: 92px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.timeline-item time { color: var(--muted); font-weight: 700; }
.bar-row { display: grid; gap: 6px; }
.bar-label, .report-item { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.bar-track { height: 12px; background: #edf1f5; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.action-log-toolbar label:not(.search) { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; min-width: 190px; }
.action-log-toolbar input[type="datetime-local"] { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; color: var(--ink); background: #fff; }
.search { flex: 1; min-width: 240px; display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; min-height: 44px; }
.search input { border: 0; outline: 0; width: 100%; }
.toolbar select, .form-grid input, .form-grid select, .form-grid textarea, .stage-row input, .stage-row select, .document-row input, .document-row select { border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.toolbar select { min-height: 44px; padding: 0 12px; }
.table-panel { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
tr.is-unreliable td { background: #fff4f1; }
tr.is-unreliable td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
.contract-title { display: grid; gap: 4px; min-width: 0; }
.contract-title strong { font-size: 15px; overflow-wrap: anywhere; }
.contract-title span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.deadline-cell { min-width: 116px; }
.deadline-cell .contract-title strong { overflow-wrap: normal; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.badge.active, .badge.done, .badge.agreed, .badge.signed { color: var(--ok); background: #eaf7ef; }
.badge.approval, .badge.current, .badge.medium, .badge.ending { color: var(--warn); background: #fff3dd; }
.badge.draft, .badge.waiting, .badge.low { color: #436274; background: #ecf3f6; }
.badge.overdue, .badge.blocked, .badge.high, .badge.expired { color: var(--bad); background: #fff0f0; }
.progress { height: 10px; width: 110px; background: #edf1f5; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(250px,1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.kanban-column { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; min-height: 420px; }
.kanban-column h2 { margin: 0 0 12px; font-size: 16px; }
.kanban-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 10px; margin-bottom: 10px; min-width: 0; }
.kanban-card .contract-title strong,
.kanban-card .contract-title span,
.kanban-card .document-mini,
.stage-list li > span:first-child { overflow-wrap: normal; word-break: normal; hyphens: none; }
.stage-list { display: grid; gap: 7px; margin: 0; padding-left: .5ch; }
.stage-list li { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; list-style: none; font-size: 13px; color: var(--muted); min-width: 0; }
.contract-dialog { border: 0; border-radius: 8px; padding: 0; width: min(920px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.contract-dialog::backdrop { background: rgba(15,36,42,.58); }
.contract-dialog form { padding: 22px; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.form-grid input, .form-grid select, .form-grid textarea { min-height: 42px; padding: 9px 10px; color: var(--ink); }
.form-grid textarea { resize: vertical; }
.wide { grid-column: 1 / -1; }
.approval-editor, .contract-file-editor, .documents-editor, .permissions-editor { margin-top: 18px; }
.contract-dialog .approval-editor,
.contract-dialog .contract-file-editor,
.contract-dialog .documents-editor,
.contract-dialog .stage-row input,
.contract-dialog .stage-row select,
.contract-dialog .document-row input,
.contract-dialog .document-row select,
.contract-dialog .contract-file-actions select,
.contract-dialog .contract-file-card,
.contract-dialog .contract-file-empty,
.contract-dialog .documents-summary,
.contract-dialog .file-chip,
.contract-dialog .download-document-file,
.contract-dialog .remove-document,
.contract-dialog .remove-stage {
  font-size: 13px;
}
.helper-text { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.permissions-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.permissions-grid label { display: flex; align-items: center; gap: 8px; min-height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--ink); font-size: 13px; font-weight: 700; background: #f8fafb; }
.permissions-grid input { width: 16px; height: 16px; flex: 0 0 auto; }
.license-accounts { display: grid; gap: 10px; margin-top: 18px; }
.license-account-row { display: grid; grid-template-columns: minmax(180px,1fr) 145px 145px; gap: 10px; align-items: end; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #f8fafb; }
.license-account-row label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.license-account-row input { min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.license-account-row .contract-title span { overflow-wrap: normal; word-break: normal; }
.stage-row, .document-row { display: grid; gap: 10px; margin-bottom: 10px; }
.stage-row { grid-template-columns: minmax(0,1fr) minmax(0,1fr) 180px 36px; }
.stage-custom-phase:not(.is-hidden) { grid-column: 1; grid-row: 2; }
.stage-custom-assignee:not(.is-hidden) { grid-column: 2; grid-row: 2; }
.document-row { grid-template-columns: 150px 130px 145px 140px 82px minmax(110px,1fr) 104px 36px; align-items: center; }
.document-type { grid-column: 1; }
.document-custom-type:not(.is-hidden) { grid-column: 1 / 5; grid-row: 2; }
.document-number { grid-column: 2; }
.document-date { grid-column: 3; }
.document-amount { grid-column: 4; }
.file-chip { grid-column: 5; }
.document-file-name { grid-column: 6; }
.download-document-file { grid-column: 7; }
.remove-document { grid-column: 8; }
.stage-row input, .stage-row select, .document-row input, .document-row select { min-height: 40px; padding: 0 10px; }
.documents-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-bottom: 12px; }
.documents-summary div, .contract-file-card, .contract-file-empty { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #f8fafb; }
.documents-summary span, .document-file-name, .contract-file-card span { display: block; color: var(--muted); font-size: 13px; }
.documents-summary strong { display: block; margin-top: 5px; }
.contract-dialog .documents-summary strong, .contract-dialog .contract-file-card strong { font-size: 13px; }
.documents-summary em { display: block; margin-top: 6px; color: var(--warn); font-size: 12px; font-style: normal; line-height: 1.35; }
.contract-file-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.contract-file-actions select { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); padding: 0 12px; }
.contract-files-list { display: grid; gap: 10px; }
.contract-file-card { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.contract-file-card > div { min-width: 0; }
.contract-file-card-actions { display: inline-flex; gap: 8px; flex: 0 0 auto; }
.contract-file-card strong, .document-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; background: #fff; }
.document-row.is-disabled { opacity: .68; }
.document-mini { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.dialog-actions { display: grid; grid-template-columns: auto 1fr auto auto; margin-top: 20px; }
.report-item { padding: 13px 0; border-bottom: 1px solid var(--line); }
.report-item:last-child { border-bottom: 0; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .nav { grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); }
  .metrics-grid, .work-grid, .kanban { grid-template-columns: 1fr; }
  .topbar, .toolbar { flex-direction: column; align-items: stretch; }
}
@media (max-width: 680px) {
  .main { padding: 18px; }
  .nav { grid-template-columns: 1fr 1fr; }
  .metrics-grid, .form-grid, .documents-summary, .permissions-grid, .license-account-row { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .table-panel { overflow-x: auto; }
  table { min-width: 760px; }
  .stage-row, .document-row { grid-template-columns: 1fr; }
  .document-row > * { grid-column: auto !important; grid-row: auto !important; }
}
@keyframes loadingSpin {
  to { transform: rotate(360deg); }
}
@keyframes loadingPulse {
  0%, 100% { opacity: .28; transform: scale(.72); }
  50% { opacity: 1; transform: scale(1); }
}
@keyframes loadingSlide {
  0% { transform: translateX(-110%); }
  55% { transform: translateX(85%); }
  100% { transform: translateX(250%); }
}
@keyframes loadingDots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75%, 100% { content: "..."; }
}
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  .sidebar, .topbar-actions, .toolbar, .nav, .icon-button, .ghost-button, .primary-button, .danger-button, .report-filter-panel { display: none !important; }
  .print-report-period { display: inline; }
  body { background: #fff; color: #000; }
  .app-shell, .work-grid { display: block; min-height: 0; }
  .main { padding: 0; overflow: visible; }
  .topbar { display: flex; justify-content: flex-end; align-items: flex-start; margin: 0 0 8mm; }
  .topbar-logo-card { border: 0; box-shadow: none; padding: 0; background: transparent; }
  .brand-logo-topbar { width: 42mm; max-height: 18mm; border-radius: 0; }
  .panel, .metric { box-shadow: none; break-inside: avoid; }
  .report-sections { margin-top: 0; gap: 0; }
  .report-table-panel { overflow: visible; padding: 0; border: 0; }
  .report-table-panel .panel-header { margin-bottom: 6mm; }
  .report-table-panel h2 { font-size: 16px; line-height: 1.25; }
  .report-table-wrap { overflow: visible; width: 100%; }
  .report-table-wrap table { min-width: 0; width: 100%; table-layout: fixed; font-size: 10.5px; line-height: 1.25; }
  .report-table-wrap th, .report-table-wrap td { padding: 5px 6px; white-space: normal; word-break: normal; overflow-wrap: break-word; vertical-align: top; }
  .report-table-wrap th:first-child, .report-table-wrap td:first-child { width: 34%; }
  .report-table-wrap th:not(:first-child), .report-table-wrap td:not(:first-child) { width: 16.5%; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
}
