* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
:root {
    --blue: #121f48;
    --blue-hover: #1a2d66;
    --blue-light: #e8f1fb;
    --red: #c61d23;
    --red-light: #fdecea;
    --amber: #b7860b;
    --amber-light: #fdf6e3;
    --green: #1a7a3c;
    --green-light: #e8f7ee;
    --gray-100: #f5f5f5;
    --gray-200: #e8e8e8;
    --gray-400: #aaa;
    --gray-600: #666;
    --gray-800: #222;
    --radius: 6px;
    --font: "Segoe UI", Arial, sans-serif;
}
body {
    font-family: var(--font);
    background: #f0f2f5;
    color: var(--gray-800);
    font-size: 14px;
}

/* LOGIN */
#loginScreen {
    position: fixed;
    inset: 0;
    background: #f0f2f5;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    padding: 40px 48px;
    width: 420px;
    max-width: 94vw;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}
.login-logo {
    margin-bottom: 28px;
}
.login-card h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--blue);
    margin-bottom: 6px;
}
.login-card .sub {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 28px;
}
.login-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: left;
    margin-bottom: 14px;
}
.login-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.login-field input {
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: 0.15s;
    width: 100%;
}
.login-field input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(18, 31, 72, 0.1);
}
.login-field select {
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: #fff;
    width: 100%;
}
.login-field select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(18, 31, 72, 0.1);
}
.btn-login {
    width: 100%;
    padding: 11px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    transition: 0.15s;
}
.btn-login:hover {
    background: var(--blue-hover);
}
.btn-login:disabled {
    opacity: 0.6;
    cursor: default;
}
.login-error {
    color: var(--red);
    font-size: 13px;
    margin-top: 10px;
    min-height: 20px;
}
.login-note {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 16px;
}
.pw-wrap {
    position: relative;
}
.pw-wrap input {
    padding-right: 40px;
}
.pw-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 16px;
    line-height: 1;
    padding: 2px;
}
.pw-toggle:hover {
    color: var(--gray-800);
}

/* HEADER */
header {
    background: var(--blue);
    color: #fff;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    height: 60px;
}
.hdr-div {
    width: 1px;
    height: 30px;
    background: rgba(255, 255, 255, 0.25);
}
header h1 {
    font-size: 15px;
    font-weight: 500;
    opacity: 0.95;
}
.agent-pill {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    opacity: 0.9;
}
.agent-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.logout-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 8px;
    transition: 0.15s;
}
.logout-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}
.role-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

nav {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    padding: 0 24px;
}
nav button {
    background: none;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    border-bottom: 3px solid transparent;
    transition: 0.15s;
}
nav button.active {
    color: var(--blue);
    border-bottom-color: var(--red);
}

main {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}
.panel {
    display: none;
}
.panel.active {
    display: block;
}

/* Dashboard */
.dash-welcome {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    padding: 20px 24px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    border-left: 4px solid var(--red);
}
.dash-welcome h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--blue);
    margin-bottom: 2px;
}
.dash-welcome p {
    font-size: 13px;
    color: var(--gray-600);
}
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 18px 20px;
    border: 1px solid var(--gray-200);
}
.stat-card .label {
    font-size: 12px;
    color: var(--gray-600);
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-card .value {
    font-size: 28px;
    font-weight: 600;
}
.stat-card.navy .value {
    color: var(--blue);
}
.stat-card.red .value {
    color: var(--red);
}
.stat-card.amber .value {
    color: var(--amber);
}
.stat-card.green .value {
    color: var(--green);
}
.dash-table-wrap {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}
.dash-table-wrap h2 {
    padding: 16px 20px;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 1px solid var(--gray-200);
}

/* Log */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.toolbar input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
    min-width: 320px;
    outline: none;
}
.toolbar input[type="text"]:focus {
    border-color: var(--blue);
}
.toolbar select {
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
    background: #fff;
    outline: none;
}
.btn {
    padding: 8px 18px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: 0.15s;
}
.btn-primary {
    background: var(--blue);
    color: #fff;
}
.btn-primary:hover {
    background: var(--blue-hover);
}
.btn-ghost {
    background: #fff;
    border: 1px solid var(--gray-200);
    color: var(--gray-800);
}
.btn-ghost:hover {
    background: var(--gray-100);
}
.btn-danger {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid #f5c6c2;
}
.btn-danger:hover {
    background: #fbd5d2;
}
.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}
.table-wrap {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}
th {
    background: #fafafa;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
    vertical-align: middle;
}
tr:last-child td {
    border-bottom: none;
}
tr:hover td {
    background: #fafcff;
}
td .actions {
    display: flex;
    gap: 6px;
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.b-critical {
    background: #fdecea;
    color: #a93226;
}
.b-high {
    background: #fdf0e0;
    color: #a0520e;
}
.b-medium {
    background: #fefce8;
    color: #8a6d00;
}
.b-low {
    background: var(--green-light);
    color: #1a6e32;
}
.b-open {
    background: var(--blue-light);
    color: #154a88;
}
.b-progress {
    background: #e8f0fd;
    color: #1a4fa0;
}
.b-escalated {
    background: #fdecea;
    color: #a93226;
}
.b-closed {
    background: var(--green-light);
    color: #1a6e32;
}
.b-withdrawn {
    background: var(--gray-100);
    color: var(--gray-600);
}
.b-query {
    background: #fdf6e3;
    color: #8a6d00;
}
.b-case {
    background: #e8f1fb;
    color: #154a88;
}
.b-followup {
    background: #e8f1fb;
    color: #154a88;
}
.b-followup-due {
    background: #fdecea;
    color: #a93226;
}
.b-followup-done {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* Modal */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.overlay.open {
    display: flex;
}
.modal {
    background: #fff;
    border-radius: 10px;
    width: 740px;
    max-width: 96vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}
.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
}
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--gray-400);
    line-height: 1;
}
.modal-close:hover {
    color: var(--gray-800);
}
.modal-body {
    padding: 24px;
}
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid .full {
    grid-column: 1/-1;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.field input,
.field select,
.field textarea {
    padding: 9px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: #fff;
    transition: 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(18, 31, 72, 0.1);
}
.field textarea {
    resize: vertical;
    min-height: 80px;
}
.field.required label::after {
    content: " *";
    color: var(--red);
}
.days-display {
    padding: 9px 12px;
    background: var(--gray-100);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--gray-600);
    font-weight: 500;
}
.section-title {
    grid-column: 1/-1;
    font-size: 12px;
    font-weight: 700;
    color: var(--blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid var(--gray-200);
}

.case-no-badge {
    font-size: 13px;
    font-weight: 700;
    color: var(--blue);
    background: var(--blue-light);
    padding: 4px 10px;
    border-radius: 4px;
}
.expand-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--gray-200);
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    color: var(--blue);
    font-weight: 700;
}
.expand-btn:hover {
    background: var(--blue-light);
}
.expanded-row td {
    background: #fbfcff;
    padding: 0;
    border-bottom: 1px solid var(--gray-200);
}
.expanded-content {
    padding: 18px 22px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.expanded-section {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 14px;
}
.expanded-section.full {
    grid-column: 1/-1;
}
.expanded-section h3 {
    font-size: 13px;
    color: var(--blue);
    margin-bottom: 10px;
}
.mini-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mini-item {
    padding: 9px 10px;
    background: var(--gray-100);
    border-radius: var(--radius);
    font-size: 12px;
    line-height: 1.45;
}
.mini-meta {
    color: var(--gray-600);
    font-size: 11px;
    margin-bottom: 3px;
}
.contact-list a {
    color: var(--blue);
    font-weight: 600;
    text-decoration: none;
}
.contact-list a:hover {
    text-decoration: underline;
}
.quick-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    margin-top: 12px;
    align-items: start;
}
.quick-form textarea {
    grid-column: 1/3;
    min-height: 58px;
}
.quick-form input,
.quick-form select,
.quick-form textarea {
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 12px;
    font-family: inherit;
}
.followup-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}
.followup-card.overdue {
    border-left: 4px solid var(--red);
}

.info-box {
    background: #fffbea;
    border: 1px solid #f0d060;
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 12px;
    color: #7a5c00;
    margin-bottom: 20px;
    line-height: 1.6;
}
.info-box strong {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
}

/* Settings */
.settings-card {
    max-width: 900px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 24px;
}
.settings-card h2 {
    font-size: 16px;
    color: var(--blue);
    margin-bottom: 8px;
}
.settings-card p {
    color: var(--gray-600);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 18px;
}
.settings-row {
    display: grid;
    grid-template-columns: 260px 1fr auto;
    gap: 12px;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}
.settings-row:last-child {
    border-bottom: none;
}
.settings-row input,
.settings-row textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}
.settings-row input:focus,
.settings-row textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(18, 31, 72, 0.1);
}
.settings-row textarea {
    min-height: 70px;
    resize: vertical;
}
.settings-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}
.settings-msg {
    min-height: 18px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--green);
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-grid .full {
        grid-column: 1;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .login-card {
        padding: 28px 24px;
    }
}
