:root {
    --navy: #15283d;
    --blue: #1769aa;
    --blue-dark: #11558c;
    --background: #f4f6f8;
    --border: #dfe4ea;
    --text: #25313d;
    --muted: #697784;
    --white: #fff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    min-height: 66px;
    padding: 0 5vw;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--navy);
    color: var(--white);
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; color: white; font-size: 1.2rem; font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 5px; background: white; }
.brand-copy { display: grid; line-height: 1.1; }
.brand-copy small { margin-top: 4px; color: #cdd9e5; font-size: .68rem; font-weight: 500; }
.brand-mark { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px; background: var(--blue); color: white; font-weight: 800; }
.brand-mark-large { width: 52px; height: 52px; margin-bottom: 8px; font-size: 1.5rem; }
.header-actions { display: flex; align-items: center; gap: 24px; }
.header-actions a, .link-button { color: #e9f0f7; }
.header-actions form { margin: 0; }
.link-button { border: 0; padding: 0; background: transparent; font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

.brand-copy { position: relative; min-width: 0; padding-left: 14px; }
.brand-copy::before { position: absolute; top: 2px; bottom: 2px; left: 0; width: 1px; background: rgba(233, 240, 247, .35); content: ""; }
.brand-copy strong { font-size: 1.04rem; font-weight: 700; letter-spacing: .02em; }

.page-shell { width: min(1180px, 92vw); margin: 42px auto; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading.compact { margin-top: 18px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; color: var(--navy); font-size: clamp(1.7rem, 3vw, 2.25rem); }
h2 { font-size: 1.1rem; color: var(--navy); }
.eyebrow { margin-bottom: 4px; color: var(--blue); font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.muted { color: var(--muted); }

.button:focus-visible, button:not(.link-button):focus-visible, input[type="submit"]:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(23, 105, 170, .26); outline-offset: 2px; }
.button:disabled, button:disabled { cursor: not-allowed; opacity: .6; }
.button, button:not(.link-button), input[type="submit"] { min-height: 42px; border: 1px solid var(--blue); border-radius: 7px; padding: 10px 17px; background: var(--blue); color: var(--white); font: inherit; font-weight: 600; line-height: 1.2; cursor: pointer; }
.button:hover, button:not(.link-button):hover, input[type="submit"]:hover { background: var(--blue-dark); text-decoration: none; }
.button.button-secondary { border-color: var(--border); background: var(--white); color: var(--text); }
.button.button-secondary:hover { border-color: var(--blue); background: #f5f7f9; color: var(--text); }
.button-full { width: 100%; }

.panel { overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: white; box-shadow: 0 2px 7px rgba(25, 45, 65, .04); }
.panel-heading { padding: 18px 22px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.panel-heading h2 { margin: 0; }
.count { min-width: 25px; padding: 2px 7px; border-radius: 999px; background: #e7f1fa; color: var(--blue); text-align: center; font-size: .8rem; font-weight: 700; }
.dashboard-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.summary-card { display: grid; gap: 3px; min-height: 132px; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--white); box-shadow: 0 2px 7px rgba(25, 45, 65, .04); }
.summary-card__label { color: var(--muted); font-size: .78rem; font-weight: 750; letter-spacing: .045em; text-transform: uppercase; }
.summary-card strong { color: var(--navy); font-size: 2rem; line-height: 1.1; }
.summary-card__hint { color: var(--muted); font-size: .82rem; }
.activity-panel { margin-bottom: 22px; }
.activity-list { display: grid; }
.activity-item { display: grid; grid-template-columns: minmax(105px, .3fr) minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px 22px; border-bottom: 1px solid #edf0f3; color: var(--text); }
.activity-item:last-child { border-bottom: 0; }
.activity-item:hover { background: #f9fbfc; text-decoration: none; }
.activity-item__ticket { color: var(--blue-dark); font-weight: 750; }
.activity-item__subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-item__meta { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 14px 16px; border-bottom: 1px solid #edf0f3; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .75rem; letter-spacing: .035em; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f9fbfc; }
.ticket-link { font-weight: 700; white-space: nowrap; }
.empty-state { padding: 44px; color: var(--muted); text-align: center; }
.badge { display: inline-block; border-radius: 999px; padding: 4px 9px; background: #edf1f4; color: #52606c; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.priority-alta, .priority-urgente { background: #fdeaea; color: #a13232; }
.status-abierto, .status-en_proceso { background: #e7f1fa; color: #155b91; }
.status-resuelto, .status-cerrado { background: #e4f4e9; color: #246b3b; }
.status-esperando_cliente { background: #fff1d9; color: #865b11; }

.login-card { width: min(420px, 100%); margin: 8vh auto; padding: 34px; border: 1px solid var(--border); border-radius: 12px; background: white; box-shadow: 0 8px 30px rgba(21, 40, 61, .08); }
.login-heading { margin-bottom: 28px; text-align: center; }
.portal-logo { width: min(180px, 70%); height: 64px; margin-bottom: 12px; object-fit: contain; }
.portal-code { margin-bottom: 2px; color: var(--blue); font-size: 1.05rem; font-weight: 800; letter-spacing: .08em; }
.login-heading h1 { margin-bottom: 4px; font-size: clamp(1.45rem, 4vw, 1.9rem); }
.login-heading p { color: var(--muted); }
.stacked-form { display: grid; gap: 20px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--navy); font-size: .9rem; font-weight: 650; }
.errorlist { margin: 0; padding: 0; color: #a13232; font-size: .85rem; list-style: none; }
.form-errors { padding: 12px; border-radius: 7px; background: #fdeaea; color: #8e2929; }
.remember-field { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .9rem; }
.remember-field input { width: 16px; height: 16px; accent-color: var(--blue); }
.remember-field label { cursor: pointer; }
.password-reset-link { margin: 20px 0 0; text-align: center; font-size: .9rem; }
.future-access { display: grid; gap: 3px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); text-align: center; font-size: .88rem; }
.reset-message > p { margin-bottom: 24px; text-align: center; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.form-panel { padding: 24px; }
.narrow-content { width: min(720px, 100%); margin: auto; }
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.account-grid .panel { min-width: 0; }
.account-grid h2 { margin-bottom: 18px; }
.account-current-email { margin-bottom: 18px; overflow-wrap: anywhere; font-weight: 600; }
.account-form-card h1 { margin-bottom: 8px; font-size: 1.6rem; }
.company-users-panel { overflow: visible; }
.company-user-actions { display: grid; gap: 7px; min-width: 220px; }
.company-user-actions form { display: flex; align-items: center; gap: 7px; margin: 0; }
.company-user-actions select { min-height: 38px; min-width: 145px; border: 1px solid #cbd3dc; border-radius: 7px; padding: 7px 9px; background: var(--white); color: var(--text); font: inherit; }
.company-user-actions .button { min-height: 38px; padding: 8px 11px; font-size: .82rem; white-space: nowrap; }
.back-link { font-size: .9rem; font-weight: 650; }
.message { margin-bottom: 20px; padding: 12px 15px; border-radius: 7px; background: #e4f4e9; color: #246b3b; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 22px; }
.detail-main, .detail-sidebar { padding: 22px; }
.detail-main > h2, .detail-sidebar > h2 { margin-bottom: 15px; }
.description { white-space: normal; overflow-wrap: anywhere; }
.detail-list { margin: 0; }
.detail-list div { padding: 11px 0; border-bottom: 1px solid #edf0f3; }
.detail-list div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-size: .76rem; font-weight: 700; letter-spacing: .025em; text-transform: uppercase; }
.detail-list dd { margin: 3px 0 0; overflow-wrap: anywhere; }

.ticket-attachments { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--border); }
.attachment-list { margin: 10px 0 0; padding: 0; list-style: none; }
.attachment-list li { margin-bottom: 8px; overflow-wrap: anywhere; }
.attachment-list span { display: block; color: var(--muted); font-size: .8rem; }
.attachment-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 3px; font-size: .86rem; }
.attachment-thumbnail { display: block; width: min(150px, 100%); height: 90px; margin: 7px 0; border: 1px solid var(--border); border-radius: 6px; background: #f7f9fb; object-fit: contain; }
.message-attachments { margin-top: 12px; padding-top: 10px; border-top: 1px solid #edf0f3; }
.inline-upload-form { display: grid; gap: 8px; margin-top: 18px; }
.inline-upload-form button { justify-self: start; }
.field-group { display: grid; gap: 7px; }
.field-group textarea, .field-group input[type="file"], .inline-upload-form input[type="file"] { width: 100%; }
.field-group small, .inline-upload-form small { color: var(--muted); }

/* Shared portal controls */
.field input, .field select, .field textarea, .field-group input, .field-group select, .field-group textarea, .inline-upload-form input[type="file"] {
    min-height: 44px;
    border: 1px solid #cbd3dc;
    border-radius: 7px;
    padding: 10px 12px;
    background: var(--white);
    color: var(--text);
    font: inherit;
    font-size: .95rem;
}

.field textarea, .field-group textarea { min-height: 120px; resize: vertical; }
.portal-textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    min-height: 120px;
    border: 1px solid #cbd3dc;
    border-radius: 7px;
    padding: 10px 12px;
    background: var(--white);
    color: var(--text);
    font: inherit;
    font-size: .95rem;
    line-height: 1.5;
    resize: vertical;
}
.portal-textarea:focus { outline: 3px solid rgba(23, 105, 170, .15); border-color: var(--blue); }
.field input:focus, .field select:focus, .field textarea:focus, .field-group input:focus, .field-group select:focus, .field-group textarea:focus { outline: 3px solid rgba(23, 105, 170, .15); border-color: var(--blue); }
.field small, .field-group small, .inline-upload-form small { color: var(--muted); font-size: .82rem; }
.inline-upload-form input[type="file"] { padding: 7px; background: #fbfcfd; }
.inline-upload-form input[type="file"]::file-selector-button, .field-group input[type="file"]::file-selector-button { margin-right: 10px; border: 1px solid var(--border); border-radius: 5px; padding: 7px 11px; background: var(--white); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; }
.inline-upload-form input[type="file"]::file-selector-button:hover, .field-group input[type="file"]::file-selector-button:hover { border-color: var(--blue); color: var(--blue-dark); }

.portal-file-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.portal-file-picker input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.portal-file-picker__button { display: inline-flex; align-items: center; min-height: 42px; border: 1px solid var(--border); border-radius: 7px; padding: 9px 14px; background: var(--white); color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; }
.portal-file-picker__button:hover { border-color: var(--blue); color: var(--blue-dark); }
.portal-file-picker:focus-within { outline: 3px solid rgba(23, 105, 170, .15); outline-offset: 2px; border-radius: 7px; }
.portal-file-picker__name { min-width: 0; overflow: hidden; color: var(--muted); font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }

.conversation-panel { margin-top: 22px; }
.conversation-panel > .panel-heading { padding: 18px 22px; }
.conversation-list { display: grid; gap: 12px; padding: 18px 22px 4px; }
.conversation-message { padding: 15px 16px; border: 1px solid var(--border); border-radius: 8px; background: #fbfcfd; }
.conversation-message header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 9px; }
.conversation-message header strong { color: var(--navy); font-weight: 650; }
.conversation-message header time { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.conversation-message > div { padding-top: 10px; border-top: 1px solid #edf0f3; overflow-wrap: anywhere; }
.conversation-panel > .stacked-form { display: flex; flex-direction: column; gap: 16px; margin: 18px 22px 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.conversation-reply-title { margin: 0; color: var(--navy); font-size: 1rem; font-weight: 650; }
.conversation-panel > .stacked-form > .conversation-submit { align-self: flex-end; display: inline-flex; width: auto; max-width: max-content; }
.conversation-list > p { margin: 0; padding: 3px 0 8px; color: var(--muted); }

.detail-list div { padding: 12px 0; }
.detail-list dt { font-size: .7rem; font-weight: 700; letter-spacing: .08em; }
.detail-list dd { color: var(--text); font-size: .95rem; font-weight: 550; }
.detail-list div:first-child dd { color: var(--blue-dark); font-size: 1.05rem; font-weight: 700; }

@media (max-width: 760px) {
    .page-shell { margin-top: 26px; }
    .page-heading { align-items: flex-start; }
    .detail-layout { grid-template-columns: 1fr; }
    .dashboard-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .account-grid { grid-template-columns: 1fr; }
    .site-header { padding-inline: 4vw; }
    .site-header { min-height: 74px; gap: 14px; }
    .header-actions { gap: 12px; font-size: .88rem; }
    .brand-logo { width: 34px; height: 34px; }
    .brand-copy small { font-size: .62rem; }
    .brand-copy strong { font-size: .96rem; }
    .page-heading { flex-wrap: wrap; }
    .page-heading > .button { width: 100%; text-align: center; }
    .detail-main, .detail-sidebar { padding: 18px; }
    .conversation-list { padding-inline: 16px; }
    .conversation-panel > .stacked-form { margin-inline: 16px; }
    .conversation-message header { align-items: flex-start; flex-direction: column; gap: 3px; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .button { width: 100%; text-align: center; }
    .activity-item { grid-template-columns: 1fr auto; gap: 4px 12px; }
    .activity-item__subject { grid-column: 1 / -1; grid-row: 2; }
    .activity-item__meta { grid-column: 2; grid-row: 1; }
    .company-user-actions { min-width: 190px; }
    .company-user-actions form { align-items: stretch; flex-direction: column; }
}
