/* EC Patch 575 — System-Wide Visual Modernization
   Presentation only: preserve document order, semantics, and control behavior. */
:root {
  --ec-text: #1f2933;
  --ec-muted: #52606d;
  --ec-border: #cbd2d9;
  --ec-border-strong: #9aa5b1;
  --ec-surface: #ffffff;
  --ec-surface-soft: #f5f7fa;
  --ec-surface-header: #e9eef3;
  --ec-accent: #174ea6;
  --ec-accent-dark: #123b7a;
  --ec-focus: #0b57d0;
  --ec-danger: #9b1c1c;
  --ec-radius: .35rem;
  --ec-shadow: 0 1px 2px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  color: var(--ec-text);
  background: var(--ec-surface);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}
body > header,
body > nav,
body > #live-message,
body > #ec-status-announcer,
body > #ec-alert-announcer,
body > main,
body > footer,
body > p[role="status"] {
  width: min(96%, 100rem);
  margin-left: auto;
  margin-right: auto;
}
body > header { padding: .85rem 0 .35rem; }
body > header p { margin: 0; font-size: 1.12rem; font-weight: 700; }

/* Main navigation: visual treatment only; existing menu buttons and ARIA stay intact. */
body > nav { border-bottom: 1px solid var(--ec-border); padding: .25rem 0 .7rem; }
body > nav > ul { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
body > nav > ul > li { margin: 0; }
body > nav > ul > li > a,
body > nav > ul > li > button {
  display: inline-block;
  min-height: 2.2rem;
  padding: .42rem .7rem;
  border: 1px solid transparent;
  border-radius: var(--ec-radius);
  background: transparent;
  color: var(--ec-text);
  font: inherit;
  text-decoration: none;
}
body > nav > ul > li > a:hover,
body > nav > ul > li > button:hover { background: var(--ec-surface-soft); border-color: var(--ec-border); }
nav [role="menu"] {
  min-width: 12rem;
  border-color: var(--ec-border-strong) !important;
  border-radius: var(--ec-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.16);
  padding: .3rem !important;
}
nav [role="menu"] a,
nav [role="menu"] button { width: 100%; border-radius: .2rem; text-align: left; }
nav [role="menu"] a:hover,
nav [role="menu"] button:hover { background: var(--ec-surface-soft); }

main { padding: 1.15rem 0 1.75rem; }
h1 { margin: 0 0 1rem; font-size: clamp(1.65rem, 2.2vw, 2.15rem); line-height: 1.2; }
h2 { margin: 1.35rem 0 .65rem; font-size: 1.35rem; line-height: 1.25; }
h3 { margin: 1rem 0 .5rem; font-size: 1.1rem; }
p { margin: .55rem 0; }
a { color: #174ea6; }
a:hover { text-decoration-thickness: 2px; }

/* Strong, consistent keyboard focus. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--ec-focus);
  outline-offset: 2px;
}

/* Commands and controls. */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
  min-height: 2.15rem;
  padding: .38rem .7rem;
  border: 1px solid var(--ec-border-strong);
  border-radius: var(--ec-radius);
  background: #fff;
  color: var(--ec-text);
  font: inherit;
  cursor: pointer;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover { background: var(--ec-surface-soft); border-color: #6b7785; }
button:disabled,
input:disabled,
select:disabled,
textarea:disabled { cursor: not-allowed; opacity: .65; }
.page-toolbar,
.calendar-toolbar,
.calendar-topbar,
.calendar-actions { gap: .45rem !important; align-items: center !important; }
.page-toolbar { padding: .25rem 0; }
.page-toolbar a,
.page-toolbar button { margin-right: 0 !important; }

/* Forms: spacing and grouping only; field order and behavior are unchanged. */
form { max-width: 100%; }
fieldset {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--ec-border);
  border-radius: var(--ec-radius);
  background: var(--ec-surface);
}
legend { padding: 0 .35rem; font-weight: 700; }
label { font-weight: 600; }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="password"], input[type="search"], input[type="date"], input[type="time"],
select, textarea {
  max-width: 100%;
  min-height: 2.15rem;
  padding: .38rem .5rem;
  border: 1px solid var(--ec-border-strong);
  border-radius: .25rem;
  background: #fff;
  color: var(--ec-text);
  font: inherit;
}
textarea { min-height: 6rem; line-height: 1.4; }
input[type="checkbox"], input[type="radio"] { margin-right: .3rem; }

/* Tables remain semantic tables; only presentation changes. */
table {
  width: 100%;
  margin: .75rem 0 1.25rem;
  border-collapse: collapse;
  border: 1px solid var(--ec-border);
  background: var(--ec-surface);
  font-size: .94rem;
}
th, td {
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--ec-border);
  vertical-align: top;
  text-align: left;
}
th {
  background: var(--ec-surface-header);
  font-weight: 700;
  border-bottom-color: var(--ec-border-strong);
}
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: #f2f6fb; }
th button {
  min-height: auto;
  padding: .15rem .25rem;
  border-color: transparent;
  background: transparent;
  font-weight: 700;
  text-align: left;
}
th button:hover { border-color: var(--ec-border-strong); background: #fff; }
td button, td .action-menu-button { white-space: nowrap; }
.row-action-menu {
  border-color: var(--ec-border-strong) !important;
  border-radius: var(--ec-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.16);
}

/* Dashboard summary cards. */
.dashboard-card-grid { gap: .85rem !important; margin: .75rem 0 1.25rem !important; }
.dashboard-card {
  border-color: var(--ec-border) !important;
  border-radius: .5rem !important;
  background: var(--ec-surface);
  box-shadow: var(--ec-shadow);
  padding: .9rem !important;
}
.dashboard-card h3 { font-size: 1.08rem; }
.dashboard-card-links li { border-top-color: #dde3e8 !important; }
.dashboard-card-links a { padding: .6rem .2rem !important; }
.dashboard-card-count { font-variant-numeric: tabular-nums; }

/* Disclosures, filters, tabs, and informational panels. */
details {
  margin: .65rem 0;
  border: 1px solid var(--ec-border);
  border-radius: var(--ec-radius);
  background: var(--ec-surface);
}
details > summary { padding: .6rem .75rem; font-weight: 700; cursor: pointer; }
details[open] > summary { border-bottom: 1px solid var(--ec-border); background: var(--ec-surface-soft); }
details > :not(summary) { margin-left: .75rem; margin-right: .75rem; }
.filter-panel {
  margin: .35rem 0 .8rem !important;
  padding: .75rem !important;
  border: 1px solid var(--ec-border);
  border-radius: var(--ec-radius);
  background: var(--ec-surface-soft);
}
[role="tablist"] { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--ec-border); margin: .75rem 0; }
[role="tab"] { border-radius: .3rem .3rem 0 0; }
[role="tab"][aria-selected="true"] { background: var(--ec-surface-header); border-bottom-color: var(--ec-surface-header); font-weight: 700; }

/* Dialog appearance without changing dialog semantics or focus behavior. */
[role="dialog"] {
  border-radius: .5rem;
}
.modal-dialog:not([hidden]),
.ec-modal-panel-force {
  box-shadow: 0 12px 30px rgba(0,0,0,.22);
}

/* Status/flash content and footer. */
#live-message:not(:empty) { margin-top: .65rem; }
.ec-server-flash-message { padding: .65rem .8rem; border: 1px solid var(--ec-border); border-radius: var(--ec-radius); background: var(--ec-surface-soft); }
body > p[role="status"] { margin-top: .65rem; }
footer { padding: .8rem 0 1.25rem; border-top: 1px solid var(--ec-border); color: var(--ec-muted); font-size: .9rem; }
footer p { margin: 0; }

/* Keep compact operational pages usable on narrower viewports. */
@media (max-width: 48rem) {
  body > header, body > nav, body > #live-message, body > main, body > footer, body > p[role="status"] { width: 94%; }
  body > nav > ul { gap: .2rem; }
  body > nav > ul > li > a, body > nav > ul > li > button { padding: .35rem .5rem; }
  th, td { padding: .45rem; }
  table { font-size: .9rem; }
}

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