:root {
  --ink: #17201b;
  --muted: #667169;
  --line: #d9e0dc;
  --bg: #f7f8f5;
  --panel: #ffffff;
  --green: #276749;
  --green-dark: #174633;
  --gold: #b7791f;
  --red: #b83232;
  --blue: #2b6cb0;
  --shadow: 0 10px 24px rgba(23, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px clamp(16px, 3vw, 34px);
  background: #0f2e22;
  color: #fff;
  box-shadow: var(--shadow);
}

.topbar h1,
.panel h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: inherit;
  opacity: 0.78;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.user-switch {
  display: grid;
  gap: 5px;
  min-width: 240px;
  font-size: 13px;
}

.session-box {
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: 220px;
  font-size: 13px;
}

.session-box button {
  padding: 7px 10px;
}

.auth-view {
  min-height: calc(100vh - 94px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-view.hidden,
.shell.hidden,
.hidden {
  display: none !important;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.nav-link {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-link.active,
.nav-link:hover {
  background: #fff;
  color: #0f2e22;
}

.shell {
  width: min(1880px, calc(100% - 20px));
  margin: 10px auto 28px;
  display: grid;
  gap: 16px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.notice,
.filters,
.panel,
.cards article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.notice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 12px 14px;
  color: #34423a;
  font-size: 13px;
}

.filters {
  padding: 14px;
}

.filter-grid,
.capture-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  color: #324039;
  font-size: 13px;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid #cbd5cf;
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  font-weight: 400;
}

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

.wide {
  grid-column: span 2;
}

select[multiple] {
  min-height: 110px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7e9;
}

.checkbox-line input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.filter-actions,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 9px;
  border-radius: 999px;
  background: #e8f2ed;
  color: #174633;
  font-size: 12px;
  font-weight: 700;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--green-dark);
}

.button-link {
  display: inline-block;
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.button-link:hover {
  background: var(--green-dark);
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.daily-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(130px, 0.6fr) minmax(100px, 0.5fr) auto auto;
  gap: 12px;
  align-items: end;
}

.daily-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.daily-totals article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfb;
}

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

.daily-totals strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.period-banner {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  background: #e8f2ed;
  color: #174633;
  font-weight: 700;
}

.period-banner.closed {
  background: #fde8e8;
  color: #8a1f1f;
}

.period-banner.reopened {
  background: #fff7db;
  color: #744210;
}

.daily-table {
  min-width: 1780px;
  border-collapse: separate;
  border-spacing: 0;
}

.daily-table th,
.daily-table td {
  padding: 6px;
}

.daily-table thead th {
  position: sticky;
  top: 0;
  z-index: 8;
  height: 38px;
  background: #1f3f31;
  color: #fff;
}

.daily-table thead tr:first-child th {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18);
}

.daily-table thead tr.daily-filter-row th {
  top: 38px;
  z-index: 7;
  background: #edf2f7;
  color: #17201b;
  box-shadow: 0 1px 0 var(--line);
}

.daily-filter-row input {
  padding: 7px 8px;
  font-size: 12px;
  background: #fff;
}

.daily-table input,
.daily-table select,
.daily-table textarea {
  min-width: 120px;
  border-color: transparent;
  background: transparent;
  padding: 6px;
}

.daily-table input:focus,
.daily-table select:focus,
.daily-table textarea:focus {
  border-color: var(--blue);
  background: #fff;
  outline: none;
}

.daily-table .amount-cell,
.daily-table .money-input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.daily-table .description-cell,
.daily-table th:nth-child(9) {
  min-width: 360px;
  white-space: normal;
}

.daily-table .daily-description {
  display: block;
  width: 100%;
  min-width: 340px;
  min-height: 38px;
  line-height: 1.35;
  overflow: hidden;
  resize: vertical;
  white-space: pre-wrap;
}

.daily-warning {
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

.save-state {
  color: var(--muted);
  min-width: 70px;
}

.cards article {
  padding: 16px;
}

.cards span {
  color: var(--muted);
  font-size: 13px;
}

.cards strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.panel {
  padding: 14px;
  overflow: hidden;
}

.daily-program-panel {
  padding: 10px;
}

.count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.daily-table-wrap {
  max-height: calc(100vh - 178px);
  position: relative;
}

table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #1f3f31;
  color: #fff;
  text-align: left;
  padding: 10px;
  white-space: nowrap;
}

td {
  border-top: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: top;
}

td.amount,
td.number {
  text-align: right;
  white-space: nowrap;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf2f7;
  font-weight: 700;
  white-space: nowrap;
}

.status.pagado,
.status.conciliado,
.status.active,
.status.cargado,
.status.validado {
  background: #e6ffef;
  color: var(--green-dark);
}

.status.autorizado,
.status.programado,
.status.pendiente_revision {
  background: #fff7df;
  color: var(--gold);
}

.status.borrador,
.status.enviado,
.status.observado,
.status.pendiente_autorizacion,
.status.inactive,
.status.rechazado,
.status.sustituido {
  background: #fff0f0;
  color: var(--red);
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
  align-items: start;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  background: #edf2f7;
  color: #26332d;
}

.tab.active {
  background: var(--blue);
  color: #fff;
}

.quick-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.quick-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.quick-item strong {
  display: block;
}

.quick-item small {
  color: var(--muted);
}

.capture-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

.company-filters {
  grid-template-columns: minmax(240px, 2fr) minmax(160px, 0.6fr);
  margin-top: 14px;
}

.companies-table {
  min-width: 1200px;
}

.section-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.company-row-number {
  width: 58px;
  text-align: center;
  color: #171717;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.logo-cell,
.company-logo {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e8f2ed;
  color: #174633;
  font-weight: 800;
}

.company-logo {
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  padding: 3px;
}

.company-logo-preview {
  display: grid;
  gap: 6px;
  align-content: start;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.company-logo-form-preview {
  width: 96px;
  height: 96px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions button.secondary,
button.secondary {
  background: #edf2f7;
  color: #26332d;
}

.row-actions button.danger,
button.danger {
  background: #b83232;
}

.hidden {
  display: none;
}

.company-detail-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.company-detail-header h2 {
  margin: 0 0 4px;
}

.company-detail-header p {
  margin: 0;
  color: var(--muted);
}

.company-tabs {
  flex-wrap: wrap;
  margin-top: 12px;
}

.company-tab-content {
  margin-top: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfb;
}

.detail-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.company-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  max-height: 72vh;
  overflow: auto;
}

.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 12px 16px;
}

#companyDialog {
  width: min(1050px, calc(100% - 28px));
}

.capture-form hr {
  grid-column: 1 / -1;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
}

.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox input {
  width: auto;
}

.capture-form button,
.form-message {
  grid-column: 1 / -1;
}

.form-message {
  margin: 0;
  min-height: 20px;
  color: var(--green-dark);
}

dialog {
  width: min(900px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

#closeDialog {
  background: #edf2f7;
  color: var(--ink);
}

pre {
  margin: 0;
  padding: 16px;
  white-space: pre-wrap;
  max-height: 70vh;
  overflow: auto;
}

@media (max-width: 1050px) {
  .filter-grid,
  .capture-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cards,
  .split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  .filter-actions,
  .panel-head,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .user-switch {
    min-width: 0;
  }

  .main-nav {
    width: 100%;
  }

  .nav-link {
    flex: 1 1 140px;
    text-align: center;
  }

  .daily-toolbar,
  .daily-totals,
  .filter-grid,
  .capture-form,
  .company-form-grid,
  .detail-grid,
  .company-filters,
  .cards,
  .split {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }
}

.bank-filters {
  grid-template-columns: minmax(240px, 2fr) repeat(5, minmax(140px, 1fr));
  margin-top: 14px;
}

.bank-table {
  min-width: 1180px;
}

.statement-filters {
  grid-template-columns: minmax(240px, 2fr) repeat(7, minmax(120px, 1fr));
  margin-top: 14px;
}

.statement-table {
  min-width: 1600px;
}

.statement-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.statement-upload-summary {
  margin: 0 16px 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: #324039;
  font-size: 13px;
}

.document-frame {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.masked-account {
  font-weight: 800;
  white-space: nowrap;
}

.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--green);
  border: 1px solid var(--line);
}

@media (max-width: 720px) {
  .bank-filters,
  .statement-filters {
    grid-template-columns: 1fr;
  }
}

/* Paso 5.1 - Identidad visual Macbull Corporativo */
:root {
  --ink: #000000;
  --muted: #5f6368;
  --line: #d9dde3;
  --bg: #f7f7f7;
  --panel: #ffffff;
  --black-soft: #171717;
  --accent: #f7af41;
  --accent-dark: #df9629;
  --row-alt: #fafafa;
  --green: #276749;
  --green-dark: #174633;
  --gold: #b7791f;
  --red: #b83232;
  --blue: #2b6cb0;
  --shadow: 0 12px 26px rgba(0, 0, 0, 0.08);
  --focus-ring: 0 0 0 3px rgba(247, 175, 65, 0.28);
}

body {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}

body.auth-mode .topbar {
  display: none;
}

.topbar {
  align-items: center;
  padding: 14px clamp(14px, 2vw, 28px);
  background: var(--black-soft);
  border-bottom: 3px solid var(--accent);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 270px;
}

.brand-logo-frame {
  width: 160px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
}

.brand-logo,
.auth-logo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.topbar h1,
.panel h2 {
  font-size: 26px;
  font-weight: 750;
}

.topbar .eyebrow {
  color: #fff;
  opacity: 0.82;
}

.selected-company {
  margin: 0;
  color: #f2f2f2;
  font-size: 14px;
  font-weight: 600;
}

.session-box {
  min-width: 260px;
  color: #fff;
}

.session-box span {
  font-size: 14px;
  font-weight: 600;
}

.main-nav {
  flex: 1 1 auto;
  justify-content: center;
  gap: 10px;
}

.nav-link {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 15px;
  font-weight: 650;
}

.nav-link.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.nav-link:hover {
  background: #2a2a2a;
  color: #fff;
  border-color: var(--accent);
}

.nav-link.active:hover {
  background: var(--accent-dark);
  color: #000;
}

.auth-view {
  min-height: 100vh;
  padding: 28px 18px;
  background: radial-gradient(circle at 50% -10%, #fff 0, #f7f7f7 42%, #eeeeee 100%);
}

.auth-card {
  width: min(440px, 100%);
  gap: 15px;
  padding: 30px 28px;
  border-color: var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.10);
}

.auth-logo {
  width: min(280px, 100%);
  margin: 0 auto 8px;
}

.auth-card .eyebrow {
  margin: 0;
  color: var(--muted);
  opacity: 1;
  text-align: center;
}

.auth-card h2 {
  text-align: center;
  font-size: 26px;
  line-height: 1.2;
}

label {
  gap: 6px;
  color: #171717;
  font-size: 14px;
  font-weight: 650;
}

select,
input,
textarea {
  min-height: 40px;
  border-color: var(--line);
  border-radius: 7px;
  color: #000;
  font-size: 15px;
  line-height: 1.45;
  background: #fff;
}

.auth-card input {
  min-height: 44px;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  outline: none;
}

button,
.button-link {
  min-height: 40px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #000;
  font-size: 15px;
  font-weight: 650;
}

button:hover,
.button-link:hover {
  background: var(--accent-dark);
  color: #000;
}

button:focus-visible,
.button-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

button:disabled,
button[disabled] {
  background: #e3e5e8 !important;
  border-color: #d1d5db !important;
  color: #666 !important;
  cursor: not-allowed;
}

.row-actions button.secondary,
button.secondary,
#closeDialog {
  background: #fff;
  color: #000;
  border-color: var(--line);
}

.row-actions button.secondary:hover,
button.secondary:hover,
#closeDialog:hover {
  background: #f1f3f4;
  color: #000;
}

.row-actions button.danger,
button.danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.row-actions button.danger:hover,
button.danger:hover {
  background: #952626;
  color: #fff;
}

.notice,
.filters,
.panel,
.cards article,
.detail-field,
.quick-item,
.statement-upload-summary {
  border-color: var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

.panel {
  border-radius: 8px;
}

.daily-program-panel {
  padding: 12px;
}

.daily-totals article,
.cards article {
  position: relative;
  border-color: var(--line);
  background: #fff;
}

.daily-totals article::before,
.cards article::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 8px 0 0 8px;
  background: var(--accent);
}

.daily-totals span,
.cards span,
.detail-field span,
.quick-item small,
.count {
  color: var(--muted);
  font-size: 13px;
}

.daily-totals strong {
  font-size: 22px;
}

.cards strong {
  font-size: 26px;
}

.period-banner {
  border: 1px solid #b7ebc6;
  background: #e6ffef;
  color: var(--green-dark);
}

.period-banner.closed {
  border-color: #f3b4b4;
  background: #fff0f0;
  color: var(--red);
}

.period-banner.reopened {
  border-color: #f7d289;
  background: #fff7df;
  color: #6c4300;
}

.table-wrap {
  border-color: var(--line);
  background: #fff;
}

table,
.daily-table {
  font-size: 14px;
}

th,
.daily-table thead th {
  background: #000;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}

.daily-table thead tr.daily-filter-row th {
  background: #f1f3f4;
  color: #171717;
  border-bottom: 1px solid var(--line);
}

td {
  border-top-color: var(--line);
}

tbody tr:nth-child(even) {
  background: var(--row-alt);
}

tbody tr:hover {
  background: #fff7e9;
}

.daily-table input,
.daily-table select,
.daily-table textarea {
  font-size: 14px;
}

.daily-table input:focus,
.daily-table select:focus,
.daily-table textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: var(--focus-ring);
}

.daily-table td:first-child,
.daily-table th:first-child {
  text-align: center;
}

.daily-table .amount-cell,
.daily-table .money-input,
td.amount,
td.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.daily-table tbody td:last-child {
  min-width: 310px;
  white-space: nowrap;
}

.daily-table tbody td:last-child select,
.daily-table tbody td:last-child button {
  width: auto;
  min-width: 0;
  min-height: 34px;
  margin-right: 5px;
  padding: 6px 8px;
  vertical-align: middle;
}

.form-message {
  color: var(--green-dark);
  font-size: 15px;
}

#loginMessage,
#changePasswordMessage,
#companyFormMessage,
#userFormMessage {
  color: var(--red);
}

.status {
  font-size: 13px;
  border: 1px solid transparent;
}

.status.pagado,
.status.conciliado,
.status.active,
.status.cargado,
.status.validado {
  border-color: #b7ebc6;
}

.status.autorizado,
.status.programado,
.status.pendiente_revision {
  border-color: #f7d289;
}

.status.borrador,
.status.enviado,
.status.observado,
.status.pendiente_autorizacion,
.status.inactive,
.status.rechazado,
.status.sustituido {
  border-color: #f3b4b4;
}

.tab {
  background: #fff;
  color: #171717;
  border-color: var(--line);
}

.tab.active {
  background: #000;
  color: #fff;
  border-color: var(--accent);
}

dialog {
  border-radius: 8px;
}

.dialog-head {
  background: #fff;
}

.dialog-head h2 {
  font-size: 18px;
}

.logo-cell,
.company-logo {
  background: #fff7e9;
  color: #000;
}

.compact-head {
  margin-top: 18px;
}

.form-hint,
.permission-summary,
.section-meta {
  color: var(--muted);
  font-size: 13px;
}

.permission-summary {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7e9;
}

.role-form {
  display: grid;
  gap: 14px;
  margin: 16px 0 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.role-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.permission-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.permission-card,
.role-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.permission-card {
  padding: 14px;
}

.permission-card-head,
.role-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.permission-card h3,
.role-card h3 {
  margin: 0;
}

.permission-options {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.permission-option {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  padding: 7px 8px;
  border-radius: 8px;
  background: #f8faf9;
}

.permission-option input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.role-sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.role-sticky-actions .form-message {
  margin-right: auto;
}

.role-list {
  display: grid;
  gap: 12px;
}

.role-card {
  padding: 14px;
}

.dashboard-panel {
  display: grid;
  gap: 14px;
}

.dashboard-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(150px, 0.8fr) minmax(120px, 0.6fr) auto;
  gap: 10px;
  align-items: end;
  min-width: min(760px, 100%);
}

.dashboard-cards {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.system-cards {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.system-detail-grid {
  margin-top: 12px;
}

.dashboard-work-search {
  width: min(420px, 100%);
  margin-left: auto;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
}

.chart-panel {
  min-height: 390px;
}

.chart-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 18px;
  align-items: center;
}

.pie-chart {
  display: grid;
  min-height: 280px;
  place-items: center;
}

.pie-donut {
  position: relative;
  display: grid;
  width: min(280px, 72vw);
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(23, 32, 27, 0.08);
}

.pie-donut::after {
  position: absolute;
  inset: 24%;
  content: "";
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px var(--line);
}

.pie-donut span {
  position: relative;
  z-index: 1;
  font-size: 22px;
  font-weight: 800;
}

.chart-legend {
  display: grid;
  gap: 10px;
  align-content: center;
}

.legend-item {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 9px;
  align-items: start;
}

.legend-item strong,
.legend-item small {
  display: block;
}

.legend-item small {
  color: var(--muted);
  margin-top: 2px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  margin-top: 2px;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px minmax(180px, 1fr) 140px;
  gap: 12px;
  align-items: center;
}

.bar-row span {
  color: #34423a;
  font-size: 13px;
  font-weight: 700;
}

.bar-row strong {
  text-align: right;
}

.bar-track {
  height: 18px;
  overflow: hidden;
  border: 1px solid #e1e6e2;
  border-radius: 999px;
  background: #f0f2ef;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f5a623, #276749);
}

.empty-chart {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .topbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .brand-block,
  .session-box {
    flex: 1 1 260px;
  }

  .main-nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .dashboard-controls,
  .dashboard-grid,
  .chart-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-cards {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .system-cards {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 720px) {
  body {
    font-size: 16px;
  }

  .topbar {
    gap: 12px;
    padding: 12px;
    flex-direction: column;
  }

  .brand-block {
    flex: 0 1 auto;
    min-width: 0;
    align-items: flex-start;
  }

  .brand-logo-frame {
    width: 112px;
    padding: 5px;
  }

  .topbar h1,
  .panel h2,
  .auth-card h2 {
    font-size: 24px;
  }

  .selected-company {
    font-size: 13px;
  }

  .main-nav {
    order: 0;
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
  }

  .nav-link {
    flex: 0 0 auto;
    min-height: 44px;
    font-size: 15px;
  }

  .session-box {
    flex: 0 1 auto;
    min-width: 0;
    justify-items: stretch;
  }

  .auth-view {
    padding: 18px;
  }

  .auth-card {
    padding: 24px 20px;
  }

  .auth-logo {
    width: min(240px, 100%);
  }

  select,
  input,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  button,
  .button-link {
    min-height: 44px;
  }

  table,
  .daily-table {
    font-size: 14px;
  }

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

  .role-card {
    display: grid;
  }

  .dashboard-cards {
    grid-template-columns: 1fr;
  }

  .system-cards {
    grid-template-columns: 1fr;
  }

  .dashboard-controls {
    min-width: 0;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bar-row strong {
    text-align: left;
  }
}
