/* SolwedTramitaciones: one stylesheet for every page. */

/* AEAT and Obligaciones */
.aeat{--aeat-bg:var(--card,#fff);--aeat-text:var(--foreground,#21323b);--aeat-muted:var(--muted-foreground,#586b74);--aeat-line:var(--border,#d7e0e4);--aeat-tint:var(--muted,#f3f6f7);--aeat-accent:var(--accent,#ffe000);max-width:1600px;color:var(--aeat-text)}
[data-theme="solwed-dark"] .aeat,[data-bs-theme="dark"] .aeat{--aeat-bg:var(--card,#252f34);--aeat-text:var(--foreground,#f1f5f6);--aeat-muted:var(--muted-foreground,#c0cdd3);--aeat-line:var(--border,#4b5c65);--aeat-tint:var(--muted,#1c252a)}
.aeat *{box-sizing:border-box}
.aeat h1{font-size:clamp(1.5rem,2vw,2.1rem);font-weight:700}
.aeat h2{font-size:1.15rem;margin:0 0 1rem;font-weight:600}
.aeat p{overflow-wrap:anywhere}
.aeat-section-head{display:flex;align-items:center;justify-content:space-between;gap:1rem;flex-wrap:wrap}
.aeat-muted{color:var(--aeat-muted);font-size:.9rem}
.aeat-nav{display:flex;flex-wrap:wrap;gap:.35rem;border-bottom:1px solid var(--aeat-line);margin:1rem 0 1.25rem;padding-bottom:.5rem}

.aeat-card{min-width:0;padding:clamp(1rem,2vw,1.5rem);margin-bottom:1.3rem}
.aeat-grid-2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1.3rem}
.aeat-editor-grid{display:grid;grid-template-columns:minmax(320px,.9fr) minmax(320px,1.1fr);gap:1.3rem}
.aeat label{display:block;font-size:.9rem;margin-bottom:1rem}
.aeat .form-control,.aeat .form-select{margin-top:.35rem;width:100%;background-color:var(--aeat-bg);color:var(--aeat-text);border-color:var(--aeat-line);min-height:44px;border-radius:8px}
.aeat input::placeholder,.aeat textarea::placeholder{color:var(--aeat-muted)}
.aeat fieldset{border:1px solid var(--aeat-line);padding:1rem;border-radius:.5rem;margin:1rem 0}
.aeat legend{font-size:1rem;width:auto;float:none;padding:0 .3rem}
.aeat-inline,.aeat-actions{display:flex;gap:.75rem;flex-wrap:wrap;align-items:end}
.aeat-inline label{flex:1;min-width:140px;margin-bottom:0}
.aeat-inline{margin:1rem 0}
.aeat .btn{white-space:normal;min-height:44px;display:inline-flex;align-items:center;justify-content:center;gap:.4rem}
.aeat-table{max-width:100%;width:100%;table-layout:fixed;border-collapse:collapse;margin-bottom:1rem}
.aeat-table :is(th,td){overflow-wrap:anywhere}
.aeat-table .btn{max-width:100%}
.aeat-table th,.aeat-table td{padding:.65rem .5rem;border-bottom:1px solid var(--aeat-line);text-align:left;vertical-align:top}
.aeat-table th{color:var(--aeat-muted);font-size:.85rem;font-weight:600}
.aeat-badge{display:inline-block;padding:.2rem .6rem;border-radius:999px;font-size:.8rem;font-weight:600}
.aeat-badge.proposed{background:#e2e3e5;color:#41464b}
.aeat-badge.pending{background:#cfe2ff;color:#0a3066}
.aeat-badge.preparing{background:#fff3cd;color:#6a4d00}
.aeat-badge.submitted{background:#d1e7dd;color:#0f5132}
.aeat-badge.not_applicable{background:#f8d7da;color:#842029}
.aeat-empty{padding:1rem;border:1px dashed var(--aeat-line);border-radius:8px;color:var(--aeat-muted)}
.aeat .btn-outline-primary,.aeat .btn-outline-secondary{color:var(--aeat-text);border-color:var(--aeat-muted)}
.aeat .btn-outline-primary:hover,.aeat .btn-outline-secondary:hover{background:var(--aeat-tint);color:var(--aeat-text)}
.aeat table a{color:inherit}
.aeat code{background:var(--aeat-tint);padding:.1rem .3rem;border-radius:4px}
.aeat-alert{padding:.7rem 1rem;border-radius:8px;border:1px solid var(--aeat-line);margin-bottom:1rem}
.aeat-alert.warning{background:#fff3cd;border-color:#ffe69c;color:#664d03}
.aeat-alert.success{background:#d1e7dd;border-color:#a3cfbb;color:#0f5132}
.aeat-alert.danger{background:#f8d7da;border-color:#f1aeb5;color:#842029}
.aeat :is(a,button,input,select,textarea,summary):focus-visible{outline:3px solid var(--ring,#b08924);outline-offset:3px}
.aeat [hidden]{display:none!important}
.aeat-sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
.aeat h1,.aeat h2,.aeat h3{overflow-wrap:anywhere}
.aeat-check{min-height:44px;display:flex!important;align-items:center;gap:.5rem}
.aeat-check input{flex:none;width:1.1rem;height:1.1rem}
@media(max-width:900px){
 .aeat-table,.aeat-table tbody{display:block;table-layout:auto}
 .aeat-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
 .aeat-table tbody{display:grid;gap:1rem}
 .aeat-table tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.7rem 1rem;border:1px solid var(--aeat-line);border-radius:8px;padding:1rem}
 .aeat-table td{display:block;border:0;padding:0;min-width:0}
 .aeat-table td:first-child,.aeat-table td[colspan]{grid-column:1/-1}
 .aeat-table td[data-label]::before{content:attr(data-label);display:block;color:var(--aeat-muted);font-size:.8rem;font-weight:600;margin-bottom:.2rem}
}
@media(max-width:480px){.aeat-table tr{grid-template-columns:minmax(0,1fr)}}
.aeat-note{padding:.7rem 1rem;border:1px solid var(--aeat-line);border-radius:8px;background:var(--aeat-tint)}
@media(max-width:900px){.aeat-grid-2,.aeat-editor-grid{grid-template-columns:minmax(0,1fr)}}
@media(max-width:480px){.aeat{padding-left:10px;padding-right:10px}.aeat-inline{align-items:stretch;flex-direction:column}.aeat-card{padding:1rem}.aeat-actions>.btn,.aeat-actions>form{flex:1}.aeat-actions>form>.btn{width:100%}}

/* Use SOLWED tokens for identifiable controls in both themes. */
.aeat .form-control,.aeat .form-select,.aeat .btn-outline-primary,.aeat .btn-outline-secondary{border-color:var(--aeat-muted)}
[data-theme="solwed-dark"] .aeat{color-scheme:dark}
/* The host dark theme declares input borders with !important. Keep its palette,
   but use the readable secondary-text token for control boundaries. */
.aeat .form-control,.aeat .form-select{border-color:var(--aeat-muted)!important}
[data-bs-theme="dark"] .aeat{color-scheme:dark}
[data-theme="solwed-dark"] .aeat :is(.form-control,.form-select):not(:focus){border-color:var(--aeat-muted)!important}

/* Junta */
.junta {color:var(--foreground,#273336);min-width:0;overflow-wrap:anywhere}
.junta .card-shadcn {background:var(--card,#fff);color:var(--card-foreground,var(--foreground,#273336))}
.junta .btn,.junta select {min-height:44px;white-space:normal}
.junta form {min-width:0;max-width:100%}
.junta select {width:100%;max-width:100%}
.junta input:not([type=hidden]):not([type=checkbox]),.junta textarea {min-height:44px;max-width:100%}
.junta fieldset {min-width:0}
.junta input[type=checkbox] {width:20px;height:20px;flex-shrink:0}
.junta .alert {background:var(--muted,#edf0f1);color:var(--foreground,#273336);border:1px solid var(--border,#b7c0c4)}
.junta a:focus-visible,.junta button:focus-visible,.junta select:focus-visible,.junta input:focus-visible,.junta textarea:focus-visible {outline:3px solid var(--ring,#657176);outline-offset:3px}
@media(max-width:576px){.junta .d-flex>form,.junta .d-flex>.btn{width:100%;flex-basis:100%}.junta form>.btn{width:100%}}

/* Shared layout for every Tramitaciones page: header, company selector, panel.
   Uses the SOLWED theme tokens; the dark theme's --border is almost the card
   colour, so visible lines derive from --muted-foreground instead. */
.tram-header,.tram-panel,.tram-hub{--tram-line:color-mix(in oklab,var(--muted-foreground,#586b74) 45%,transparent);--tram-muted:var(--muted-foreground,#586b74);--tram-tint:var(--muted,#f3f6f7)}
.tram-header{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:1rem 2rem;margin-bottom:1.5rem}
.tram-header-text{min-width:0;flex:1 1 320px}
.tram-header h1{font-size:clamp(1.5rem,2vw,2.1rem);font-weight:700;margin:0 0 .25rem}
.tram-company{margin:0;font-weight:600}
.tram-subtitle{margin:.35rem 0 0;color:var(--tram-muted)}
.tram-back{display:inline-flex;align-items:center;gap:.45rem;min-height:44px;margin-bottom:.5rem;color:inherit;font-weight:600;text-decoration:none}
.tram-back:hover{text-decoration:underline}
.tram-company-form{flex:0 1 26rem;min-width:min(100%,18rem)}
.tram-company-form label{display:block;font-size:.85rem;font-weight:600;margin-bottom:.35rem}
.tram-company-row{display:flex;gap:.5rem}
.tram-company-row .form-select{flex:1;min-width:0;min-height:44px;background-color:var(--card,#fff);color:var(--foreground,#21323b);border:1px solid var(--tram-muted)!important;border-radius:8px}
.tram-header .btn-outline-secondary,.tram-panel .btn-outline-secondary,.tram-hub .btn-outline-secondary{min-height:44px;color:var(--foreground,#21323b);border-color:var(--tram-muted);background:transparent}
.tram-header .btn-outline-secondary:hover,.tram-panel .btn-outline-secondary:hover,.tram-hub .btn-outline-secondary:hover{background:var(--tram-tint);color:var(--foreground,#21323b)}
.tram-header :is(a,button,select):focus-visible,.tram-panel :is(a,button,select):focus-visible,.tram-hub :is(a,button):focus-visible{outline:3px solid var(--ring,#b08924);outline-offset:3px}

/* Panel */
.tram-kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(11rem,1fr));gap:1rem;margin-bottom:1.5rem}
.tram-kpi{display:block;padding:1rem 1.1rem;border-radius:10px;border:1px solid var(--tram-line);background:var(--card,#fff);color:inherit;text-decoration:none;min-width:0}
a.tram-kpi:hover{border-color:var(--tram-muted)}
.tram-kpi-label{display:block;font-size:.85rem;color:var(--tram-muted);font-weight:600}
.tram-kpi-value{display:block;font-size:2rem;font-weight:700;line-height:1.2;margin-top:.25rem}
.tram-kpi-note{display:block;font-size:.8rem;color:var(--tram-muted)}
.tram-kpi.is-alert{border-left:4px solid var(--destructive,#d9534f)}
.tram-kpi.is-warn{border-left:4px solid var(--accent,#ffe000)}
.tram-grid{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);gap:1.25rem;margin-bottom:1.25rem}
.tram-card{padding:clamp(1rem,2vw,1.4rem);border-radius:10px;border:1px solid var(--tram-line);background:var(--card,#fff);min-width:0}
.tram-card h2{font-size:1.1rem;font-weight:600;margin:0 0 1rem}
.tram-list{list-style:none;margin:0;padding:0}
.tram-list li{display:flex;gap:.9rem;align-items:flex-start;padding:.7rem 0;border-bottom:1px solid var(--tram-line)}
.tram-list li:last-child{border-bottom:0}
.tram-list a{color:inherit;font-weight:600}
.tram-date{flex:none;width:4.2rem;text-align:center;border-radius:8px;padding:.3rem 0;background:var(--tram-tint);font-weight:700;line-height:1.1}
.tram-date small{display:block;font-weight:600;font-size:.72rem;text-transform:uppercase;color:var(--tram-muted)}
.tram-date.is-overdue{background:var(--destructive,#d9534f);color:#fff}
.tram-date.is-overdue small{color:#fff}
.tram-meta{display:block;font-size:.85rem;color:var(--tram-muted)}
.tram-pill{display:inline-block;padding:.1rem .55rem;border-radius:999px;font-size:.75rem;font-weight:600;border:1px solid var(--tram-line);color:var(--tram-muted);margin-left:.35rem;vertical-align:middle}
.tram-pill.is-alert{border-color:var(--destructive,#d9534f);color:var(--destructive,#d9534f)}
.tram-empty{padding:1rem;border:1px dashed var(--tram-muted);border-radius:8px;color:var(--tram-muted);margin:0}
.tram-chart{position:relative;height:260px}
.tram-status{display:flex;flex-wrap:wrap;gap:.35rem .75rem;align-items:center;font-size:.85rem;color:var(--tram-muted);margin-bottom:.75rem}
.tram-dot{display:inline-block;width:.6rem;height:.6rem;border-radius:50%;background:var(--tram-muted)}
.tram-dot.is-ok{background:#2f9e5b}
.tram-dot.is-alert{background:var(--destructive,#d9534f)}
@media(max-width:992px){.tram-grid{grid-template-columns:minmax(0,1fr)}}
@media(max-width:480px){.tram-company-row{flex-direction:column}.tram-company-row .btn{width:100%}}

/* Visible controls in both themes: disabled buttons, Junta fields, empty states. */
:is(.aeat,.junta) .btn:disabled{opacity:1;background:var(--muted,#eef1f2);color:var(--muted-foreground,#586b74);border:1px dashed var(--muted-foreground,#586b74)}
.junta :is(.form-control,.form-select){background-color:var(--card,#fff);color:var(--foreground,#21323b);border:1px solid var(--muted-foreground,#586b74)!important;border-radius:8px}
.junta .btn-outline-secondary{color:var(--foreground,#21323b);border-color:var(--muted-foreground,#586b74)}
.aeat-empty{border-color:var(--muted-foreground,#586b74)}
