/* EVOX Design Freeze Phase 4 — Visual Refinement & Responsive QA */
:root{
  --evox-page-bg:#f6f8fb;
  --evox-surface:#ffffff;
  --evox-surface-soft:#f9fafb;
  --evox-surface-strong:#eef2f6;
  --evox-text:#172033;
  --evox-text-muted:#667085;
  --evox-text-subtle:#98a2b3;
  --evox-border:#e1e7ef;
  --evox-border-strong:#cbd5e1;
  --evox-primary:#173d63;
  --evox-primary-hover:#102f4e;
  --evox-primary-soft:#eaf1f8;
  --evox-success:#027a48;
  --evox-warning:#b54708;
  --evox-danger:#b42318;
  --evox-info:#175cd3;
  --evox-radius-sm:10px;
  --evox-radius-md:14px;
  --evox-radius-lg:18px;
  --evox-radius-xl:24px;
  --evox-shadow-xs:0 1px 2px rgba(16,24,40,.04);
  --evox-shadow-sm:0 2px 8px rgba(16,24,40,.06);
  --evox-shadow-md:0 12px 30px rgba(16,24,40,.09);
  --evox-content-readable:760px;
  --evox-section-gap:clamp(20px,3vw,34px);
}

html{
  background:var(--evox-page-bg);
  text-rendering:optimizeLegibility;
  -webkit-font-smoothing:antialiased;
}

body{
  background:
    radial-gradient(circle at 10% 0%,rgba(23,61,99,.045),transparent 30%),
    var(--evox-page-bg);
  color:var(--evox-text);
  overflow-wrap:anywhere;
}

body,
button,
input,
select,
textarea{
  font-family:"AbarLow","Abar",Tahoma,Arial,sans-serif;
}

::selection{
  background:rgba(23,61,99,.16);
  color:var(--evox-text);
}

img,
svg,
video,
canvas{
  max-width:100%;
  height:auto;
}

iframe{max-width:100%}

p,
li,
dd{
  line-height:1.85;
}

h1,h2,h3,h4,h5,h6{
  color:var(--evox-text);
  line-height:1.45;
  text-wrap:balance;
}

h2{font-size:clamp(1.25rem,2.3vw,1.65rem)}
h3{font-size:clamp(1.05rem,2vw,1.3rem)}

.evox-page-main > * + *{
  margin-top:var(--evox-section-gap);
}

.evox-page-main > .evox-breadcrumb + *,
.evox-page-main > .evox-page-heading + *{
  margin-top:0;
}

.evox-readable{
  max-width:var(--evox-content-readable);
}

.evox-section{
  min-width:0;
}

.evox-section-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:16px;
}

.evox-section-title{
  margin:0;
  font-size:1.18rem;
  font-weight:800;
}

.evox-section-description{
  margin:5px 0 0;
  color:var(--evox-text-muted);
  font-size:.88rem;
}

/* Cards */
.evox-card,
.card.evox-refined,
.panel.evox-refined,
.dashboard-card.evox-refined,
.widget.evox-refined{
  min-width:0;
  padding:clamp(16px,2vw,22px);
  background:var(--evox-surface);
  border:1px solid var(--evox-border);
  border-radius:var(--evox-radius-lg);
  box-shadow:var(--evox-shadow-xs);
}

.evox-card:hover{
  border-color:var(--evox-border-strong);
}

.evox-card--interactive{
  transition:transform 160ms ease,box-shadow 160ms ease,border-color 160ms ease;
}

.evox-card--interactive:hover{
  transform:translateY(-2px);
  box-shadow:var(--evox-shadow-md);
}

.evox-card-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom:16px;
}

.evox-card-title{
  margin:0;
  font-size:1rem;
  font-weight:800;
}

.evox-card-subtitle{
  margin:4px 0 0;
  color:var(--evox-text-muted);
  font-size:.82rem;
}

.evox-card-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr));
  gap:16px;
}

/* Metrics */
.evox-metric-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
}

.evox-metric{
  min-width:0;
  padding:18px;
  border:1px solid var(--evox-border);
  border-radius:var(--evox-radius-lg);
  background:linear-gradient(145deg,var(--evox-surface),var(--evox-surface-soft));
  box-shadow:var(--evox-shadow-xs);
}

.evox-metric__label{
  color:var(--evox-text-muted);
  font-size:.8rem;
  font-weight:700;
}

.evox-metric__value{
  display:block;
  margin-top:8px;
  color:var(--evox-text);
  font-size:clamp(1.35rem,2.5vw,1.9rem);
  font-weight:900;
  line-height:1.2;
}

.evox-metric__meta{
  display:block;
  margin-top:7px;
  color:var(--evox-text-muted);
  font-size:.76rem;
}

/* Status badges */
.evox-badge,
.badge.evox-refined,
.status.evox-refined{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  min-height:28px;
  padding:3px 9px;
  border:1px solid transparent;
  border-radius:999px;
  font-size:.74rem;
  font-weight:800;
  white-space:nowrap;
}

.evox-badge--neutral{background:#f2f4f7;color:#475467;border-color:#e4e7ec}
.evox-badge--success{background:#ecfdf3;color:#027a48;border-color:#abefc6}
.evox-badge--warning{background:#fffaeb;color:#b54708;border-color:#fedf89}
.evox-badge--danger{background:#fef3f2;color:#b42318;border-color:#fecdca}
.evox-badge--info{background:#eff8ff;color:#175cd3;border-color:#b2ddff}

/* Better controls */
.evox-btn{
  min-height:42px;
  max-width:100%;
  padding-inline:15px;
  border-radius:11px;
  font-weight:750;
  text-decoration:none;
  text-align:center;
  line-height:1.35;
}

.evox-btn--primary{
  background:var(--evox-primary);
  border-color:var(--evox-primary);
  color:#fff;
}

.evox-btn--primary:hover{
  background:var(--evox-primary-hover);
  border-color:var(--evox-primary-hover);
}

.evox-btn--secondary{
  background:var(--evox-surface);
  border-color:var(--evox-border-strong);
  color:var(--evox-text);
}

.evox-btn--danger{
  background:var(--evox-danger);
  border-color:var(--evox-danger);
  color:#fff;
}

a,
button,
input,
select,
textarea,
[tabindex]{
  scroll-margin-top:calc(var(--evox-header-h,72px) + 18px);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible{
  outline:3px solid rgba(23,61,99,.22);
  outline-offset:2px;
}

/* Authentication pages */
body.evox-auth-page{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:clamp(16px,3vw,32px);
  background:
    radial-gradient(circle at 85% 15%,rgba(23,61,99,.11),transparent 32%),
    radial-gradient(circle at 10% 90%,rgba(32,115,171,.08),transparent 28%),
    var(--evox-page-bg);
}

body.evox-auth-page.evox-shell-ready{
  display:block;
  padding-top:var(--evox-header-h,72px);
}

.evox-auth-shell{
  width:min(100%,1040px);
  display:grid;
  grid-template-columns:minmax(0,.9fr) minmax(360px,1.1fr);
  overflow:hidden;
  border:1px solid var(--evox-border);
  border-radius:var(--evox-radius-xl);
  background:var(--evox-surface);
  box-shadow:0 24px 70px rgba(16,24,40,.13);
}

.evox-auth-visual{
  min-height:560px;
  padding:clamp(24px,4vw,48px);
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  background:
    linear-gradient(145deg,rgba(10,35,60,.92),rgba(23,61,99,.78)),
    var(--evox-primary);
  color:#fff;
}

.evox-auth-visual h1,
.evox-auth-visual h2,
.evox-auth-visual p{
  color:inherit;
}

.evox-auth-form{
  min-width:0;
  padding:clamp(24px,5vw,56px);
  display:flex;
  flex-direction:column;
  justify-content:center;
}

.evox-auth-form form{
  width:100%;
}

/* Dashboard and content consistency */
.evox-dashboard-section{
  min-width:0;
}

.evox-dashboard-columns{
  display:grid;
  grid-template-columns:minmax(0,1.45fr) minmax(280px,.55fr);
  gap:18px;
}

.evox-list{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin:0;
  padding:0;
  list-style:none;
}

.evox-list-item{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  padding:13px 0;
  border-bottom:1px solid var(--evox-border);
}

.evox-list-item:last-child{border-bottom:0}

.evox-truncate{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.evox-break-safe{
  overflow-wrap:anywhere;
  word-break:normal;
}

.evox-scroll-safe{
  max-width:100%;
  overflow:auto;
  overscroll-behavior:contain;
}

/* Legacy layout normalization */
.container,
.wrapper,
.content-wrapper,
.main-wrapper{
  max-width:100%;
}

pre,
code{
  max-width:100%;
  overflow:auto;
  direction:ltr;
  text-align:left;
}

hr{
  border:0;
  border-top:1px solid var(--evox-border);
}

dialog,
.evox-modal{
  max-width:min(92vw,720px);
  max-height:88vh;
  overflow:auto;
  border:1px solid var(--evox-border);
  border-radius:var(--evox-radius-xl);
  box-shadow:0 24px 80px rgba(16,24,40,.2);
}

/* Responsive QA breakpoints */
@media (max-width:1200px){
  .evox-metric-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .evox-dashboard-columns{grid-template-columns:minmax(0,1fr)}
}

@media (max-width:900px){
  :root{--evox-section-gap:22px}

  .evox-card,
  .card.evox-refined,
  .panel.evox-refined,
  .dashboard-card.evox-refined,
  .widget.evox-refined{
    padding:16px;
    border-radius:15px;
  }

  .evox-section-header,
  .evox-card-header{
    align-items:stretch;
    flex-direction:column;
  }

  .evox-auth-shell{
    width:min(100%,620px);
    grid-template-columns:minmax(0,1fr);
  }

  .evox-auth-visual{
    min-height:210px;
    justify-content:center;
  }
}

@media (max-width:640px){
  body{font-size:15px}

  .evox-metric-grid{grid-template-columns:minmax(0,1fr)}
  .evox-card-grid{grid-template-columns:minmax(0,1fr)}

  .evox-btn,
  button,
  [role="button"],
  input[type="submit"],
  input[type="button"]{
    min-height:44px;
  }

  .evox-list-item{
    align-items:stretch;
    flex-direction:column;
  }

  .evox-auth-form{padding:22px 18px}
  .evox-auth-visual{padding:24px 20px}
}

@media (max-width:360px){
  .evox-page-layout,
  .evox-page-layout--admin{
    width:calc(100% - 12px);
  }

  .evox-card,
  .evox-form-section{
    padding:13px;
    border-radius:13px;
  }
}

@media (hover:none){
  .evox-card--interactive:hover{transform:none}
}

@media (prefers-reduced-motion:reduce){
  *,
  *::before,
  *::after{
    scroll-behavior:auto!important;
    animation-duration:.01ms!important;
    animation-iteration-count:1!important;
    transition-duration:.01ms!important;
  }
}

@media (prefers-contrast:more){
  :root{
    --evox-border:#aeb8c6;
    --evox-border-strong:#7d8999;
    --evox-text-muted:#455164;
  }
}

/* EVOX PHASE4 REPAIR2 OVERFLOW GUARDS */
html,body,main,section,article,form,fieldset,.evox-page-main,.evox-card,.evox-table-card{min-width:0;max-width:100%}
@media(max-width:900px){.evox-overflow-candidate,.table-responsive,.chart-container,.timeline,.calendar-grid{overflow-x:auto}table,pre,code,svg,canvas,iframe{max-width:100%}}
