

:root {
    --ob-dark:    #0d2140;
    --ob-mid:     #1a3a5c;
    --ob-blue:    #1e4d7b;
    --ob-teal:    #1a6e8e;
    --ob-accent:  #2196f3;
    --ob-light:   #e8f1fb;
    --ob-white:   #ffffff;
    --ob-gray:    #f4f6f9;
    --ob-border:  #dce3ec;
    --ob-text:    #1a2535;
    --ob-muted:   #6b7a8d;
    --ob-success: #2e7d32;
    --ob-error:   #c62828;
    --shadow-sm:  0 1px 3px rgba(0,0,0,.1);
    --shadow-md:  0 4px 12px rgba(0,0,0,.12);
    --shadow-lg:  0 8px 24px rgba(0,0,0,.15);
    --radius:     6px;
    --header-h:   70px;
    --nav-h:      50px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--ob-text);
    background: var(--ob-gray);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}


.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #b8ccd8 0%, #dae4ec 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--ob-white);
    border-radius: 14px;
    padding: 44px 40px 36px;
    width: 100%; max-width: 440px;
    box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 8px; }
.login-logo-img { width: 100%; max-width: 240px; height: auto; }
.login-title {
    text-align: center; font-size: 14px; font-weight: 600;
    color: var(--ob-muted); margin-bottom: 28px; letter-spacing: .3px;
}
.login-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.login-row label { width: 86px; flex-shrink: 0; font-weight: 700; font-size: 13px; color: var(--ob-text); }
.login-row input {
    flex: 1; height: 42px; padding: 0 10px;
    border: 1.5px solid var(--ob-border); border-radius: var(--radius);
    font-size: 14px; outline: none; transition: border-color .2s; min-width: 0; width: 100%;
}
.login-row input:focus { border-color: var(--ob-accent); }
.btn-login {
    display: block; width: 100%; padding: 13px; margin-top: 22px;
    background: linear-gradient(135deg, var(--ob-dark), var(--ob-blue));
    color: white; border: none; border-radius: var(--radius);
    font-size: 15px; font-weight: 700; cursor: pointer; letter-spacing: .3px;
    transition: opacity .2s, transform .1s;
}
.btn-login:hover  { opacity: .88; }
.btn-login:active { transform: scale(.98); }


.page-wrap { display: flex; flex-direction: column; min-height: 100vh; }

.site-header {
    background: var(--ob-white);
    border-bottom: 2px solid var(--ob-border);
    padding: 0 20px;
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky; top: 0; z-index: 200; gap: 12px;
}
.header-logo-img { height: 44px; width: auto; display: block; flex-shrink: 0; }
.header-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.header-date { text-align: right; line-height: 1.35; }
.header-date .date-val   { font-size: 11px; color: var(--ob-muted); }
.header-date .page-title { font-size: 16px; font-weight: 800; color: var(--ob-dark); white-space: nowrap; }
.btn-logout {
    padding: 6px 14px;
    background: transparent; border: 1.5px solid var(--ob-border); border-radius: var(--radius);
    font-size: 12px; font-weight: 600; color: var(--ob-muted); cursor: pointer; white-space: nowrap;
    transition: all .2s;
}
.btn-logout:hover { background: var(--ob-error); color: white; border-color: var(--ob-error); }

.site-nav {
    background: var(--ob-dark);
    display: flex; align-items: stretch;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    position: sticky; top: var(--header-h); z-index: 190;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
    color: rgba(255,255,255,.72); text-decoration: none;
    font-weight: 600; font-size: 13px;
    padding: 0 22px; height: var(--nav-h);
    display: flex; align-items: center; white-space: nowrap; flex-shrink: 0;
    border-bottom: 3px solid transparent; transition: all .2s;
}
.site-nav a:hover  { color: white; background: rgba(255,255,255,.08); }
.site-nav a.active { color: white; border-bottom-color: #64b5f6; background: rgba(255,255,255,.06); }

.page-content { padding: 22px 20px; flex: 1; }


.alert {
    padding: 10px 14px; border-radius: var(--radius);
    margin-bottom: 16px; font-size: 13px; font-weight: 500; line-height: 1.5;
}
.alert-error   { background: #fdecea; color: var(--ob-error);   border: 1px solid #f5c6cb; }
.alert-success { background: #e8f5e9; color: var(--ob-success); border: 1px solid #c3e6cb; }
.alert-info    { background: var(--ob-light); color: var(--ob-blue); border: 1px solid #bee1ff; }


.section-card { background: var(--ob-white); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 22px; overflow: hidden; }
.section-card-header {
    padding: 12px 16px; background: var(--ob-gray);
    border-bottom: 1px solid var(--ob-border);
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.section-card-header h3 { font-size: 15px; font-weight: 700; color: var(--ob-dark); }


.table-overflow { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
    width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 600px;
}
.data-table th {
    background: var(--ob-dark); color: white;
    padding: 9px 10px; text-align: center;
    font-weight: 600; font-size: 11.5px; letter-spacing: .3px; white-space: nowrap;
}
.data-table td {
    padding: 7px 10px; border-bottom: 1px solid var(--ob-border);
    text-align: center; vertical-align: middle;
}
.data-table tr:nth-child(even) td { background: #fafbfc; }
.data-table tr:hover td { background: var(--ob-light); }
.data-table input[type="text"],
.data-table input[type="date"],
.data-table select,
.data-table textarea {
    width: 100%; padding: 4px 6px; border: 1px solid var(--ob-border);
    border-radius: 4px; font-size: 12px; background: white; outline: none;
}
.data-table input:focus, .data-table select:focus { border-color: var(--ob-accent); }
.data-table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--ob-dark); }


.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 14px; border-radius: var(--radius); border: none;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all .2s; text-decoration: none; white-space: nowrap;
    touch-action: manipulation;
}
.btn-primary { background: var(--ob-dark); color: white; }
.btn-primary:hover { background: var(--ob-blue); }
.btn-success { background: var(--ob-success); color: white; }
.btn-success:hover { opacity: .88; }
.btn-danger  { background: var(--ob-error); color: white; }
.btn-danger:hover  { opacity: .88; }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }


.search-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.search-bar input {
    padding: 7px 11px; border: 1.5px solid var(--ob-border); border-radius: var(--radius);
    font-size: 13px; outline: none; width: 220px; max-width: 100%;
    transition: border-color .2s; height: 36px;
}
.search-bar input:focus { border-color: var(--ob-accent); }


.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 999;
    display: none; align-items: center; justify-content: center;
    padding: 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: white; border-radius: 10px; width: 100%; max-width: 680px;
    max-height: 92vh; overflow-y: auto;
    box-shadow: var(--shadow-lg); display: flex; flex-direction: column; margin: auto;
}
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--ob-border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--ob-dark); color: white;
    position: sticky; top: 0; z-index: 1; border-radius: 10px 10px 0 0; flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close {
    background: none; border: none; color: rgba(255,255,255,.7);
    font-size: 24px; cursor: pointer; line-height: 1;
    padding: 4px 6px; transition: color .2s; flex-shrink: 0;
    min-width: 36px; min-height: 36px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: white; }
.modal-body { padding: 20px; flex: 1; }
.modal-footer {
    padding: 14px 20px; border-top: 1px solid var(--ob-border);
    display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; flex-shrink: 0;
}


.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
    font-size: 11px; font-weight: 700; color: var(--ob-muted);
    text-transform: uppercase; letter-spacing: .5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 10px; border: 1.5px solid var(--ob-border); border-radius: var(--radius);
    font-size: 13px; outline: none; transition: border-color .2s; width: 100%; min-height: 40px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--ob-accent); }
.form-group textarea { resize: vertical; min-height: 72px; }
.form-required::after { content: ' *'; color: var(--ob-error); }


.inicio-widgets { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 22px; }
.widget-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; min-height: 100px; }
.widget-card h4 {
    font-size: 14px; font-weight: 700; color: var(--ob-dark);
    margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--ob-light);
}


.ts-badge {
    display: inline-block; font-size: 9.5px; color: var(--ob-muted);
    background: var(--ob-gray); border-radius: 3px; padding: 2px 5px;
    max-width: 115px; word-break: break-all; line-height: 1.3;
}
.select-pill {
    display: inline-block; padding: 3px 9px; border-radius: 12px;
    font-size: 11px; font-weight: 600; background: var(--ob-light); color: var(--ob-dark);
}
#toast-container {
    position: fixed; bottom: 20px; right: 20px; z-index: 9999;
    display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 40px);
}


@media (max-width: 900px) {
    .inicio-widgets { grid-template-columns: 1fr; }
    .header-date .page-title { font-size: 14px; }
    .header-logo-img { height: 38px; }
    .section-card-header { flex-direction: column; align-items: flex-start; }
    .section-card-header > div { width: 100%; justify-content: flex-start; }
    .search-bar { width: 100%; }
    .search-bar input { flex: 1; min-width: 0; width: auto; }
    .modal-footer { justify-content: stretch; }
    .modal-footer .btn { flex: 1; justify-content: center; }
    .modal-box { max-width: 96vw; }
}


@media (max-width: 600px) {
    :root { --header-h: 56px; --nav-h: 44px; }


    .site-header { padding: 0 12px; gap: 8px; }
    .header-logo-img { height: 28px; }
    .header-date .page-title { font-size: 10px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .header-date .date-val { display: none; }
    .btn-logout { padding: 5px 9px; font-size: 11px; }


    .site-nav a { padding: 0 12px; font-size: 11px; }


    .login-card { padding: 28px 18px 24px; border-radius: 10px; }
    .login-logo-img { max-width: 180px; }
    .login-row { flex-direction: column; align-items: flex-start; gap: 4px; }
    .login-row label { width: auto; font-size: 12px; }
    .login-row input { width: 100%; height: 46px; font-size: 16px; }


    .page-content { padding: 12px 10px; }


    .section-card-header { padding: 10px 12px; gap: 8px; }
    .section-card-header h3 { font-size: 14px; }
    .section-card-header > div { flex-direction: column !important; align-items: stretch !important; }
    .section-card-header .btn { width: 100%; justify-content: center; }


    .btn { padding: 10px 12px; font-size: 12px; min-height: 40px; }
    .btn-sm { padding: 7px 10px; font-size: 11px; min-height: 34px; }


    .modal-overlay { padding: 0; align-items: flex-end; overflow: hidden; }
    .modal-box { max-width: 100%; width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; margin: 0; }
    .modal-header { border-radius: 16px 16px 0 0; }
    .modal-body { padding: 16px; }
    .modal-footer { padding: 12px 16px; }
    .modal-footer .btn { flex: 1; justify-content: center; }


    .form-grid { grid-template-columns: 1fr; gap: 12px; }
    .form-group input,
    .form-group select,
    .form-group textarea { font-size: 16px; min-height: 46px; }
    .form-group textarea { font-size: 14px; min-height: 72px; }


    .data-table { font-size: 10.5px; }
    .data-table th { padding: 6px 5px; font-size: 9.5px; }
    .data-table td { padding: 5px 5px; }
    .data-table input[type="text"],
    .data-table input[type="date"],
    .data-table select { font-size: 11px; padding: 3px 3px; }


    .inicio-widgets { gap: 10px; }
    .widget-card { padding: 12px; }


    #toast-container { bottom: 10px; right: 8px; left: 8px; max-width: 100%; }


    .bienvenida { padding: 14px 14px !important; border-radius: var(--radius) !important; }
    .bienvenida h2 { font-size: 16px !important; }
    .bienvenida p { font-size: 12px !important; }
    .poliza-card-header { padding: 10px 12px !important; }
    .poliza-card-header h4 { font-size: 13px !important; }
    .poliza-card-body { padding: 12px !important; }
    .poliza-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
    .poliza-field .lbl { font-size: 9px !important; }
    .poliza-field .val { font-size: 12px !important; }
    .status-row { gap: 10px !important; flex-wrap: wrap !important; }
    .status-item { font-size: 12px !important; }
    .tramite-row { grid-template-columns: 1fr !important; gap: 8px !important; padding: 10px 0 !important; }
    .portal-header { padding: 12px 14px !important; }
    .portal-header img { height: 30px !important; }
    .portal-info .titulo { font-size: 13px !important; }
    .portal-nav a,
    .portal-nav span { font-size: 12px !important; padding: 0 12px !important; height: 40px !important; display: flex !important; align-items: center !important; }
}


@media (max-width: 400px) {
    :root { --header-h: 50px; }
    .btn-logout { display: none; }
    .site-nav a { padding: 0 10px; font-size: 10.5px; }
    .page-content { padding: 10px 8px; }
    .poliza-grid { grid-template-columns: 1fr !important; }
}
