:root {
  color-scheme: light;
  --ink: #172539;
  --muted: #607185;
  --line: #c9d5df;
  --blue: #2579ad;
  --blue-dark: #144c78;
  --blue-soft: #e9f4fb;
  --green: #b9e4b4;
  --green-dark: #315d39;
  --yellow: #fff2b5;
  --paper: #fffdf7;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: #eaf0f4;
  font: 15px/1.42 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
.app-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 26px;
  color: #fff;
  background: linear-gradient(120deg, #15476f, #257cae);
  border-bottom: 4px solid #83bfdc;
  box-shadow: 0 2px 9px #12344e26;
}
.brand { display: flex; align-items: center; gap: 11px; font-size: 22px; font-weight: 700; letter-spacing: -.03em; }
.brand-icon { display: grid; place-items: center; width: 30px; height: 30px; color: #164c75; background: #e5f5ff; border: 2px solid #b9d8e8; border-radius: 4px; font-size: 23px; line-height: 1; }
.header-meta { font-size: 13px; color: #d5ebf7; }
.header-meta span { margin-left: 12px; padding: 5px 9px; border-radius: 999px; background: #ffffff25; color: white; }

.app-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: calc(100vh - 101px); }
.sidebar { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 68px); background: #f8fbfd; border-right: 1px solid #bfd0dc; }
.sidebar-head { padding: 23px 19px 12px; box-shadow: 0 3px 9px #244d6711; z-index: 1; }
.sidebar h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.sidebar p { margin: 4px 0 19px; color: var(--muted); font-size: 13px; }
.sidebar label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 700; color: #395468; text-transform: uppercase; letter-spacing: .06em; }
.search-row { display: flex; gap: 6px; }
.search-row input { min-width: 0; width: 100%; border: 1px solid #b9cbd8; border-radius: 5px; background: white; padding: 10px 11px; color: var(--ink); font: inherit; }
.search-row input:focus { outline: 2px solid #89c8e7; outline-offset: 1px; }
.search-row button { border: 1px solid #115684; border-radius: 5px; background: #176da3; padding: 0 11px; color: white; font: inherit; font-weight: 650; cursor: pointer; }
.search-row button:hover { background: #0e5a8d; }
.result-count { margin-top: 13px; color: var(--muted); font-size: 12px; font-weight: 650; }
.result-list { flex: 1; overflow: auto; padding: 7px 8px; }
.result { display: block; margin: 2px 0; padding: 10px 12px; text-decoration: none; border: 1px solid transparent; border-radius: 7px; }
.result:hover { background: #e9f4fb; border-color: #c9e1ef; }
.result.active { background: #deeffa; border-color: #6cb2d7; box-shadow: inset 3px 0 #207bb1; }
.result strong, .result span, .result small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result strong { color: #163b59; font-size: 13px; }
.result span { color: #405668; font-size: 12px; }
.result small { color: #788995; font-size: 11px; }
.no-results { padding: 20px 10px; }
.pager { display: flex; justify-content: space-between; gap: 4px; align-items: center; padding: 11px 12px; border-top: 1px solid #dce5eb; font-size: 12px; color: #667c8d; }
.pager a { text-decoration: none; color: #126b9e; font-weight: 700; }
.pager a:hover { text-decoration: underline; }

.workspace { min-width: 0; padding: 24px 26px 32px; }
.record-topline { display: flex; justify-content: space-between; align-items: start; gap: 20px; padding: 18px 23px 20px; background: #fff; border: 1px solid #c9d5df; border-bottom: 0; border-radius: 10px 10px 0 0; }
.eyebrow { display: block; margin-bottom: 4px; color: #477994; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.record-topline h2 { margin: 0; color: #172d4c; font-size: clamp(18px, 1.8vw, 26px); line-height: 1.2; letter-spacing: -.02em; }
.record-topline p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.separator { padding: 0 5px; }
.record-number { flex: none; color: #577386; background: #eaf3f8; border: 1px solid #cfe1ea; border-radius: 20px; padding: 5px 10px; font-size: 12px; font-weight: 700; }
.tabs { display: flex; overflow-x: auto; gap: 3px; padding: 0 12px; background: #d9e9f2; border: 1px solid #b9ccda; border-bottom: 3px solid #2d7fae; }
.tab { flex: none; padding: 11px 13px 9px; color: #31536d; border-radius: 6px 6px 0 0; text-decoration: none; font-size: 13px; font-weight: 700; white-space: nowrap; }
.tab:hover { background: #edf7fb; }
.tab.current { background: #fffdf7; color: #114d77; box-shadow: inset 0 3px #2d7fae; }
.tab-body { min-height: 520px; background: var(--paper); border: 1px solid #b9ccda; border-top: 0; border-radius: 0 0 10px 10px; padding: 23px; box-shadow: 0 7px 22px #1e496211; }
.form-grid { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(230px, 1fr) minmax(260px, 1.05fr); gap: 17px; align-items: start; }
.two-columns, .bottom-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.bottom-grid { margin-top: 17px; }
.info-panel { min-width: 0; overflow: hidden; background: white; border: 1px solid #c6d5dd; border-radius: 6px; box-shadow: 0 2px 5px #1d46630a; }
.info-panel h3 { margin: 0; padding: 9px 13px; background: #dceaf2; border-bottom: 1px solid #b9cfdb; color: #224661; font-size: 13px; letter-spacing: .01em; }
.info-panel.customer h3, .info-panel.administration h3, .info-panel.equipment h3 { background: var(--green); border-color: #9dcf9d; color: var(--green-dark); }
.panel-body { padding: 12px; }
.field { min-width: 0; margin-bottom: 8px; }
.field:last-child { margin-bottom: 0; }
.field-label { padding: 3px 7px; background: #e9f1f5; border: 1px solid #c6d6df; border-bottom: 0; border-radius: 3px 3px 0 0; color: #37566a; font-size: 11px; font-weight: 700; }
.field-value { min-height: 28px; padding: 5px 7px; background: #fffdf4; border: 1px solid #c6d6df; border-radius: 0 0 3px 3px; overflow-wrap: anywhere; font-size: 13px; }
.field.special .field-value { background: var(--yellow); }
.blank { color: #a6b1b8; }
.operator .field { margin-bottom: 12px; }
.equipment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.equipment-grid .field-label { background: var(--green); border-color: #a2caa6; }
.equipment-grid .field-value { background: #fff8d8; text-align: center; font-weight: 700; }
.info-panel.note-box { margin-top: 14px; box-shadow: none; border-color: #dfcdcd; }
.note-box h3 { background: #f7e7e7; border-color: #e4cdcd; color: #8b3038; }
.notes { min-height: 168px; color: #a82331; white-space: pre-wrap; font-size: 13px; font-weight: 650; }
.empty-note { margin: 0; color: #70828c; font-size: 13px; }
.list-panel .panel-body { min-height: 104px; }
.muted { color: var(--muted); margin: 0 0 15px; font-size: 13px; }
.raw-scroll { overflow: auto; max-height: 67vh; background: white; border: 1px solid #cbd8de; border-radius: 5px; }
.raw-table { border-collapse: collapse; width: 100%; }
.raw-table th, .raw-table td { padding: 8px 10px; border-bottom: 1px solid #e1e9ed; text-align: left; vertical-align: top; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.raw-table th { width: 230px; background: #eaf3f8; color: #35556a; position: sticky; left: 0; }
.raw-table tr:nth-child(even) td { background: #fafcfd; }
.empty-state { display: grid; place-content: center; min-height: 460px; text-align: center; background: white; border: 1px solid var(--line); border-radius: 10px; }
.empty-state h2 { margin: 0 0 5px; }
.empty-state p { margin: 0; color: var(--muted); }
footer { padding: 9px 20px; color: #687e8e; background: #e2ebf1; border-top: 1px solid #c7d5df; text-align: right; font-size: 11px; }
.logout-form { margin-left: 18px; }
.logout-form button { padding: 7px 11px; border: 1px solid #9db7c7; border-radius: 5px; color: #28506b; background: #f3f8fb; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 18px; background: #e5eef3; }
.login-card { width: min(100%, 390px); padding: 28px; background: #fffdf7; border: 1px solid #bfd0db; border-radius: 11px; box-shadow: 0 12px 38px #254d6629; }
.login-card .brand { color: #164f74; margin-bottom: 22px; }
.login-card h1 { font-size: 23px; margin: 0 0 7px; color: #194e70; }
.login-card p { color: #597284; font-size: 14px; margin: 0 0 21px; }
.login-card label { display: block; color: #33556d; font-size: 13px; font-weight: 700; margin-bottom: 7px; }
.login-card input { width: 100%; box-sizing: border-box; padding: 11px 12px; border: 1px solid #a8c1d0; border-radius: 5px; background: white; font: inherit; font-size: 16px; }
.login-card button { width: 100%; margin-top: 14px; padding: 11px; border: 0; border-radius: 5px; background: #236c96; color: white; font: inherit; font-weight: 700; cursor: pointer; }
.login-card .login-error { padding: 9px 11px; border-radius: 5px; color: #8d2632; background: #ffeaec; }

/* The record area follows the six-page Access form in the supplied photos. */
.workspace { padding: 20px; }
.legacy-window { width: 100%; min-height: 690px; border: 1px solid #839bb1; background: #e9e8d9; box-shadow: 0 3px 12px #28415120; font: 13px/1.15 Arial, Helvetica, sans-serif; }
.legacy-titlebar { height: 24px; display: flex; justify-content: space-between; align-items: center; padding: 2px 8px; color: #304556; background: linear-gradient(#eef0f0, #cfd9df); border-bottom: 1px solid #8aa5b9; }
.legacy-row-number { color: #65798a; font-size: 11px; }
.legacy-window .tabs { gap: 0; padding: 0 6px; min-height: 24px; background: #e3e5df; border: 0; border-bottom: 5px solid #6da7dc; }
.legacy-window .tab { padding: 4px 7px 3px; border: 1px solid #aab6bd; border-bottom: 0; border-radius: 0; background: #dbddda; color: #202c36; font-size: 12px; font-weight: 400; }
.legacy-window .tab.current { background: #f1efdf; color: #202c36; box-shadow: none; }
.legacy-window .tab:hover { background: #f6f6ec; }
.legacy-window .tab-body { min-height: 630px; padding: 13px 15px 16px; border: 0; border-radius: 0; background: #f1efdf; box-shadow: inset 0 0 0 5px #75a9d8; }
.legacy-window .tab-body h2 { margin: 0 0 11px; color: #253754; font-size: 14px; font-weight: 700; }
.legacy-record-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.legacy-record-heading h2 { margin: 0 !important; }
.marketing-print-button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 1px solid #879dab; background: linear-gradient(#fff, #dce7ec); color: #294b60; font: bold 12px Arial, sans-serif; cursor: pointer; }
.marketing-print-button:hover { background: #e2f1fa; }
.marketing-print-button:focus-visible { outline: 2px solid #217bac; outline-offset: 2px; }
.marketing-print-dialog { width: min(94vw, 560px); max-height: min(90vh, 760px); padding: 0; border: 1px solid #829caf; background: #f4f3e9; color: #263d4d; box-shadow: 0 18px 55px #173c5070; font: 14px/1.4 Arial, sans-serif; }
.marketing-print-dialog::backdrop { background: #142a3e8c; }
.marketing-print-dialog form { padding: 0 17px 17px; }
.print-dialog-header { display: flex; align-items: center; justify-content: space-between; margin: 0 -17px 14px; padding: 7px 12px 7px 17px; background: #d9e6ec; border-bottom: 1px solid #a6bdc7; }
.print-dialog-header h3 { margin: 0; font-size: 15px; }
.print-dialog-close { border: 0; background: transparent; color: #344c5d; font: 24px/1 Arial, sans-serif; cursor: pointer; }
.marketing-print-dialog p { margin: 0 0 12px; }
.marketing-print-dialog label { display: block; margin-bottom: 5px; font-weight: 700; }
.marketing-print-dialog textarea { display: block; width: 100%; min-height: 220px; padding: 10px; border: 1px solid #96aeb9; background: white; color: #243847; resize: vertical; font: 15px/1.45 Arial, sans-serif; }
.marketing-print-dialog textarea:focus { outline: 2px solid #65a7cf; }
.marketing-print-dialog .print-dialog-hint { margin-top: 9px; color: #536b79; font-size: 12px; }
.print-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.print-dialog-actions button { min-width: 86px; padding: 7px 12px; border: 1px solid #91a8b5; background: #e2e8e9; color: #253f52; font: bold 13px Arial, sans-serif; cursor: pointer; }
.print-dialog-actions .print-submit { border-color: #2e6e98; background: #2d78a5; color: white; }
.legacy-green { min-height: 19px; padding: 2px 4px; background: #a6d9a3; border: 1px solid #81b78d; color: #214b36; }
.legacy-cell { min-height: 19px; padding: 2px 4px; border: 1px solid #bfcbd0; border-top: 0; color: #1e292d; background: #f5f3e8; white-space: pre-wrap; overflow-wrap: anywhere; }
.legacy-cell.highlight { background: #f7edaa; }
.legacy-cell.name-line { background: #f5d6a4; }
.legacy-cell.contact-label { color: #435661; background: #e4e8e4; }
.legacy-cell.contact-value { background: #edf0eb; }
.legacy-ident-head { display: flex; justify-content: space-between; }
.legacy-ident-head span { min-width: 54px; text-align: right; }
.legacy-spacer { height: 22px; border-left: 1px solid #bfcbd0; border-right: 1px solid #bfcbd0; background: #f5f3e8; }
.legacy-marketing-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(230px, 1.17fr); gap: 13px; }
.legacy-marketing-side { padding: 0 4px; }
.legacy-margin { min-height: 20px; padding: 2px 6px; border: 1px solid #c8c389; background: #e8e450; text-align: right; color: #a25032; }
.legacy-marketing-side .legacy-cell.operator { max-width: 100%; min-height: 34px; display: grid; place-items: center; color: #a82737; font-weight: 700; background: #edb8be; border: 1px solid #d5a1a9; }
.legacy-equipment, .legacy-price-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.legacy-stat { min-width: 0; display: flex; flex-direction: column; }
.legacy-stat > span { min-height: 18px; padding: 2px 4px; background: #a6d9a3; border: 1px solid #92c49d; color: #214b36; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legacy-stat > strong { min-height: 19px; padding: 2px 4px; border: 1px solid #bfcbd0; border-top: 0; background: #f4f1e1; color: #2a3238; text-align: center; font-weight: 400; overflow-wrap: anywhere; }
.legacy-private-note { margin-top: 8px; color: #a32b37; font-weight: 700; white-space: pre-wrap; }
.legacy-marketing-bottom { display: grid; grid-template-columns: minmax(0, 1.14fr) minmax(145px, .6fr) minmax(230px, 1fr); gap: 10px; margin-top: 11px; }
.legacy-mini-tables .legacy-grid:first-child { height: 142px; }
.legacy-mini-tables .legacy-grid:last-child { height: 149px; }
.legacy-marketing-center { display: flex; flex-direction: column; justify-content: flex-end; }
.legacy-disabled-control { min-height: 28px; display: grid; place-items: center; border: 1px solid #aebcc4; background: #d9dbd8; color: #4c5660; }
.legacy-disabled-control:first-child { background: #f8edb5; }
.legacy-marketing-center .legacy-green { margin-top: 8px; }
.legacy-blank-box { min-height: 95px; border: 1px solid #bfcbd0; background: #e7e8df; }
.legacy-marketing-actions { display: flex; flex-direction: column; justify-content: flex-end; gap: 7px; }
.legacy-entry-grid { width: 100%; }
.legacy-entry-grid .legacy-stat { flex-direction: row; }
.legacy-entry-grid .legacy-stat > span { width: 36%; }
.legacy-entry-grid .legacy-stat > strong { flex: 1; border-top: 1px solid #bfcbd0; text-align: left; }
.legacy-price-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.legacy-price-grid .legacy-stat > strong { min-height: 22px; background: #fff3b3; }
.legacy-note-box { min-height: 70px; padding: 4px; border: 1px solid #b9c5c9; background: #eeefe9; color: #1c2c37; white-space: pre-wrap; overflow-wrap: anywhere; }
.legacy-marketing-actions .legacy-blank-box { min-height: 75px; }
.legacy-disabled-control.confirm { width: 45%; align-self: end; min-height: 25px; }
.legacy-grid { width: 100%; height: 100%; overflow: auto; border: 1px solid #9aadb7; background: #e5e7e7; }
.legacy-grid table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.legacy-grid th { padding: 3px 4px; border: 1px solid #6e9fbd; background: #75b5dc; color: #25465c; text-align: left; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legacy-grid td { padding: 6px 8px; border: 1px solid #c6cdcd; background: #e9ebea; color: #62737c; }
.legacy-grid.tall { height: 540px; }
.legacy-grid.tall .legacy-grid-empty { height: 500px; vertical-align: top; }
.invoice-grid th { position: sticky; top: 0; z-index: 1; }
.invoice-grid td { padding: 3px 5px; background: #eff1eb; color: #263b49; overflow-wrap: anywhere; }
.invoice-grid tr:nth-child(even) td { background: #e3e8e4; }
.invoice-grid a { color: #155a86; font-weight: 700; text-decoration: underline; }
.invoice-grid.tall table { min-width: 820px; table-layout: fixed; }
.invoice-grid.tall th:nth-child(1) { width: 24%; }
.invoice-grid.tall th:nth-child(2) { width: 9%; }
.invoice-grid.tall th:nth-child(3), .invoice-grid.tall th:nth-child(4) { width: 10%; }
.invoice-grid.tall th:nth-child(5), .invoice-grid.tall th:nth-child(6) { width: 11%; }
.invoice-grid.tall th:nth-child(7) { width: 8%; }
.invoice-grid.tall th:nth-child(8) { width: 5%; }
.invoice-grid.tall th:nth-child(9) { width: 12%; }
.legacy-invoice-footer { display: flex; justify-content: space-between; gap: 12px; padding: 8px 5px; color: #476273; font-size: 12px; }
.legacy-invoice-footer a { color: #155a86; font-weight: 700; }
.legacy-anagrafica-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(190px, .8fr); column-gap: 20px; row-gap: 14px; align-items: stretch; }
.legacy-anagrafica-layout > * { min-width: 0; }
.legacy-anagrafica-layout > .legacy-identity, .legacy-categories { display: flex; flex-direction: column; }
.legacy-anagrafica-layout > .legacy-identity::after, .legacy-categories::after { content: ""; flex: 1; border: 1px solid #bfcbd0; border-top: 0; background: #f5f3e8; }
.legacy-attributes .legacy-stat { flex-direction: row; }
.legacy-attributes .legacy-stat > span { width: 56%; background: #e2e7e7; }
.legacy-attributes .legacy-stat > strong { flex: 1; border-top: 1px solid #bfcbd0; text-align: right; }
.legacy-ttpcp { margin: 20px 0 14px; }
.legacy-ttpcp .legacy-stat > span { background: #f5f0ce; }
.legacy-checks { background: #b9e6b4; border: 1px solid #83b98b; }
.legacy-checks > div { display: flex; justify-content: space-between; min-height: 18px; padding: 1px 5px; border-bottom: 1px solid #9ac39a; }
.legacy-checks > div:last-child { border-bottom: 0; }
.legacy-check { color: #295c99; font-size: 14px; }
.legacy-contract, .legacy-reserved-note { grid-column: span 2; }
.legacy-categories .legacy-stat { flex-direction: row; }
.legacy-categories .legacy-stat > span { width: 50%; }
.legacy-categories .legacy-stat > strong { flex: 1; border-top: 1px solid #bfcbd0; background: #f8eaa8; text-align: left; }
.legacy-contract-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.legacy-contract .legacy-cell { min-height: 37px; }
.legacy-fixed-note .legacy-note-box, .legacy-reserved-note .legacy-note-box { min-height: 65px; }
.legacy-empty-tab { height: 540px; padding: 15px; border: 1px solid #c2c9ca; color: #65737b; background: #f2f1e7; }
.all-fields-link { padding: 7px 1px; font-size: 12px; }
.all-fields-link a { color: #265e82; }

@media (max-width: 1320px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid > .equipment { grid-column: 1 / -1; }
  .equipment-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .notes { min-height: 80px; }
}
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .workspace { padding: 15px; }
  .tab-body { padding: 14px; }
  .form-grid, .two-columns, .bottom-grid { grid-template-columns: 1fr; }
  .form-grid > .equipment { grid-column: auto; }
  .legacy-marketing-top, .legacy-anagrafica-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .legacy-marketing-side, .legacy-attributes { grid-column: 1 / -1; }
  .legacy-contract, .legacy-reserved-note { grid-column: auto; }
  .legacy-marketing-bottom { grid-template-columns: 1fr 1fr; }
  .legacy-marketing-actions { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .app-header { min-height: 56px; padding: 0 15px; }
  .brand { font-size: 19px; }
  .header-meta { display: none; }
  .app-layout { display: block; }
  .sidebar { max-height: none; border-right: 0; border-bottom: 1px solid #c4d5df; }
  .sidebar-head { padding: 14px; }
  .sidebar-head p { margin-bottom: 11px; }
  .result-list { max-height: 210px; }
  .workspace { padding: 12px; }
  .record-topline { padding: 14px; }
  .record-number { display: none; }
  .tabs { padding: 0 5px; }
  .tab { padding: 10px; font-size: 12px; }
  .equipment-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  footer { text-align: center; }
  .legacy-window .tab-body { padding: 11px; }
  .legacy-marketing-top, .legacy-anagrafica-layout, .legacy-marketing-bottom { grid-template-columns: 1fr; }
  .legacy-marketing-side, .legacy-attributes, .legacy-marketing-actions { grid-column: auto; }
  .legacy-grid.tall table { min-width: 650px; }
}
