:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #152033;
    --muted: #667085;
    --line: #d9e0ea;
    --primary: #137c72;
    --primary-dark: #0f5f59;
    --warning: #b7791f;
    --danger: #c2413a;
    --success: #22835b;
    --radius: 8px;
    --shadow: 0 12px 32px rgba(21, 32, 51, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: 26px;
    margin-bottom: 4px;
}

h2 {
    font-size: 18px;
    margin-bottom: 18px;
}

small,
.muted {
    color: var(--muted);
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    background: #14213d;
    color: #fff;
    padding: 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.brand.large {
    color: var(--ink);
    margin-bottom: 20px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: #f4c95d;
    color: #14213d;
    font-weight: 700;
}

.brand strong,
.brand small {
    display: block;
}

.sidebar nav {
    display: grid;
    gap: 8px;
}

.sidebar a {
    display: block;
    padding: 12px 14px;
    border-radius: var(--radius);
    color: #d9e7ff;
}

.sidebar a:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
}

.shell {
    margin-left: 248px;
    padding: 28px;
}

.auth-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.topbar p {
    margin-bottom: 0;
    color: var(--muted);
}

.panel,
.auth-card,
.metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    padding: 22px;
    margin-bottom: 22px;
}

.panel.narrow {
    max-width: 920px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.auth-card {
    width: min(100%, 420px);
    padding: 30px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.metric {
    padding: 18px;
}

.metric span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.metric strong {
    font-size: 30px;
}

.metric.danger strong {
    color: var(--danger);
}

.grid {
    display: grid;
    gap: 22px;
}

.grid.two {
    grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
}

.detail-grid {
    grid-template-columns: minmax(0, 1fr) 340px;
}

.form {
    display: grid;
    gap: 15px;
}

.grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-2 {
    grid-column: span 2;
}

label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 11px 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

textarea {
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0 16px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
}

.button.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.button.primary:hover {
    background: var(--primary-dark);
}

.button.full {
    width: 100%;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.alert {
    margin-bottom: 18px;
    border: 1px solid #acd8d2;
    border-radius: var(--radius);
    background: #e7f5f2;
    color: #0f5f59;
    padding: 12px 14px;
}

.alert.danger {
    border-color: #f1b8b5;
    background: #fff0ef;
    color: var(--danger);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td small {
    display: block;
    margin-top: 4px;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    background: #edf1f7;
    color: #344054;
    white-space: nowrap;
}

.pill.open {
    background: #eef4ff;
    color: #175cd3;
}

.pill.in_progress,
.pill.waiting_approval,
.pill.revision {
    background: #fff6df;
    color: var(--warning);
}

.pill.done {
    background: #e8f6ef;
    color: var(--success);
}

.pill.rejected {
    background: #fff0ef;
    color: var(--danger);
}

.text-danger {
    color: var(--danger);
    font-weight: 700;
}

.score {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
}

.score.good {
    background: #e8f6ef;
    color: var(--success);
}

.score.bad {
    background: #fff0ef;
    color: var(--danger);
}

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 220px 110px;
    gap: 12px;
    margin-bottom: 18px;
}

.workload {
    display: grid;
    gap: 14px;
}

.workload-row {
    display: grid;
    gap: 8px;
}

.workload-row div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.workload-row span {
    display: block;
    height: 8px;
    min-width: 12px;
    border-radius: 999px;
    background: var(--primary);
}

.ticket-title {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.ticket-title h2 {
    font-size: 24px;
}

.description {
    color: #344054;
    line-height: 1.65;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 18px 0;
}

.details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
}

.details dt {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.details dd {
    margin: 0;
    font-weight: 700;
}

.comment-form {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.timeline {
    display: grid;
    gap: 14px;
}

.timeline article {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}

.timeline strong,
.timeline small {
    display: block;
}

.timeline p {
    margin: 10px 0 0;
    line-height: 1.55;
}

.attachment-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    background: #f8fafc;
    font-weight: 700;
}

.attachment-link small {
    white-space: nowrap;
}

@media (max-width: 980px) {
    .sidebar {
        position: static;
        width: auto;
    }

    .sidebar nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .shell {
        margin-left: 0;
        padding: 18px;
    }

    .metric-grid,
    .grid.two,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .topbar,
    .ticket-title,
    .actions {
        align-items: stretch;
        flex-direction: column;
    }

    .metric-grid,
    .grid-form,
    .details,
    .filters,
    .sidebar nav {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .panel,
    .auth-card {
        padding: 18px;
    }
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.popup-content {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    max-width: 600px;
    width: 90%;
    position: relative;
    text-align: center;
}

.banner-img {
    width: 100%;
    border-radius: 8px;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
}
.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.popup-content {
    width: 650px;
    max-width: 95%;
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    cursor: pointer;
    font-size: 24px;
}

.overdue-list {
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.overdue-list li {
    margin-bottom: 10px;
    padding: 8px;
    border-left: 4px solid #dc2626;
    background: #fff5f5;
}

.overdue-list a {
    font-weight: 700;
    color: #dc2626;
    text-decoration: none;
}

.overdue-list a:hover {
    text-decoration: underline;
}

.btn-close-popup {
    margin-top: 15px;
    padding: 10px 20px;
    cursor: pointer;
}
/* Overlay */
.popup-overlay{
    position:fixed;
    inset:0;
    background:rgba(15,23,42,.75);
    backdrop-filter:blur(6px);
    display:flex;
    justify-content:center;
    align-items:center;
    z-index:99999;

    animation:fadeIn .3s ease;
}

/* Card */
.popup-card{
    width:850px;
    max-width:95%;
    background:#fff;
    border-radius:20px;
    overflow:hidden;

    box-shadow:
        0 25px 50px rgba(0,0,0,.25);

    animation:popupShow .45s ease;
}

/* Header */
.popup-header{
    display:flex;
    gap:20px;
    align-items:center;

    padding:25px 30px;

    background:
        linear-gradient(
            135deg,
            #2563eb,
            #1d4ed8
        );

    color:white;
}

.popup-header h2{
    margin:0;
}

.popup-header p{
    margin:5px 0 0;
    opacity:.9;
}

.alert-icon{
    font-size:52px;
    animation:bounce 2s infinite;
}

/* Body */
.popup-body{
    padding:25px 30px;
}

/* Table */
.overdue-table{
    width:100%;
    border-collapse:collapse;
}

.overdue-table th{
    background:#f8fafc;
    padding:14px;
    text-align:left;
    border-bottom:1px solid #e2e8f0;
}

.overdue-table td{
    padding:14px;
    border-bottom:1px solid #edf2f7;
}

.overdue-table tr:hover{
    background:#f8fafc;
}

/* Ticket Link */
.ticket-link{
    color:#dc2626;
    font-weight:700;
    text-decoration:none;
    position:relative;
}

.ticket-link:hover{
    color:#991b1b;
}

.ticket-link::after{
    content:'';
    position:absolute;
    left:0;
    bottom:-2px;
    width:0;
    height:2px;
    background:#dc2626;
    transition:.3s;
}

.ticket-link:hover::after{
    width:100%;
}

/* Footer */
.popup-footer{
    padding:20px 30px;
    display:flex;
    justify-content:flex-end;
    gap:10px;
}

.btn-primary{
    background:#2563eb;
    color:white;
    border:none;
    padding:12px 20px;
    border-radius:10px;
    cursor:pointer;
}

.btn-primary:hover{
    background:#1d4ed8;
}

.btn-secondary{
    background:#e5e7eb;
    border:none;
    padding:12px 20px;
    border-radius:10px;
    cursor:pointer;
}

.btn-secondary:hover{
    background:#d1d5db;
}

/* Animations */

@keyframes popupShow{
    from{
        opacity:0;
        transform:translateY(-40px) scale(.95);
    }
    to{
        opacity:1;
        transform:translateY(0) scale(1);
    }
}

@keyframes fadeIn{
    from{opacity:0;}
    to{opacity:1;}
}

@keyframes bounce{
    0%,100%{
        transform:translateY(0);
    }
    50%{
        transform:translateY(-8px);
    }
}
.alert-icon{
    font-size:56px;
    animation:spinGear 4s linear infinite;
}

@keyframes spinGear{
    from{
        transform:rotate(0deg);
    }
    to{
        transform:rotate(360deg);
    }
}
.popup{
    position:fixed;
    inset:0;

    background:rgba(0,0,0,.55);

    display:flex;
    justify-content:center;
    align-items:center;

    z-index:999999;

    animation:fadeIn .3s ease;
}

.popup-box{

    width:850px;
    max-width:95%;

    background:#fff;
    border-radius:20px;

    overflow:hidden;

    box-shadow:
    0 20px 50px rgba(0,0,0,.25);

    animation:slideUp .45s ease;
}

.popup-top{

    background:linear-gradient(
    135deg,
    #dc2626,
    #ef4444
    );

    color:white;

    padding:25px;

    display:flex;
    gap:20px;
    align-items:center;
}

.icon{
    font-size:60px;

    animation:shake 1.5s infinite;
}

.popup table{
    width:100%;
    border-collapse:collapse;
}

.popup th,
.popup td{
    padding:15px;
    border-bottom:1px solid #eee;
}

.popup tr:hover{
    background:#f8fafc;
}

.popup-action{
    padding:20px;
    text-align:right;
}

.popup-action button{
    background:#dc2626;
    color:white;
    border:none;
    padding:12px 25px;
    border-radius:8px;
    cursor:pointer;
}

@keyframes slideUp{
    from{
        opacity:0;
        transform:translateY(80px) scale(.9);
    }

    to{
        opacity:1;
        transform:translateY(0) scale(1);
    }
}

@keyframes fadeIn{
    from{opacity:0;}
    to{opacity:1;}
}

@keyframes shake{

    0%,100%{
        transform:rotate(0deg);
    }

    25%{
        transform:rotate(-10deg);
    }

    75%{
        transform:rotate(10deg);
    }
}