:root{
    /* Light/neutral palette */
    --app-bg: #f4f6f9;
    --app-surface: #ffffff;
    --app-surface-2: #fbfcfd;
    --app-border: rgba(0,0,0,.10);

    --app-sidebar-bg: #ffffff;

    /* Porto-ish primary */
    --app-accent: #0088cc;
    --app-accent-soft: rgba(0,136,204,.12);

    --app-text-main: #1f2937;   /* slate-ish */
    --app-text-muted: #6b7280;  /* muted grey */
}

/* Base */
html, body { height: 100%; }

body{
    margin: 0;
    background: var(--app-bg);
    color: var(--app-text-main);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Links */
a{ text-decoration: none; color: inherit; }
a:hover{ color: var(--app-text-main); }

/* Overall shell */
.app-shell{
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    color: var(--app-text-main);
}

/* TOP BAR */
.app-topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
    padding: .6rem 1rem;
}

.brand-left{
    display:flex;
    align-items:center;
    gap:.6rem;
}

.brand-logo{
    height: 30px;
    width: auto;
}

.brand-right{
    margin-left:auto;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--app-text-main);
    white-space: nowrap;
}

/* BODY LAYOUT */
.app-body{
    display:grid;
    grid-template-columns: 72px minmax(0, 1fr);
    margin: 0;
    max-width: none;
    padding: 1.25rem 1.25rem 1.25rem 0;
    gap: 1.1rem;
}

/* SIDEBAR */
.sidebar{
    background: var(--app-sidebar-bg);
    width: 64px;
    transition: width .18s ease-out;
    display:flex;
    flex-direction: column;
    padding: .75rem .4rem;

    border-right: 1px solid var(--app-border);

    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 14px;
    border-bottom-right-radius: 14px;

    position: sticky;
    margin-top: 1.25rem;
    top: calc(72px + 1.25rem);
    height: calc(100vh - 72px - 1.25rem);
    z-index: 50;
}

/* Responsive tweak to match your smaller page padding */
@media (max-width: 768px){
    .sidebar{
        margin-top: 1rem;
        top: calc(72px + 1rem);
        height: calc(100vh - 72px - 1rem);
    }
}

.sidebar:hover{ width: 220px; }

.sidebar-title{
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--app-text-muted);
    padding: 0 .6rem .25rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity .12s ease-out;
}

.sidebar:hover .sidebar-title{ opacity: 1; }

.sidebar-nav{
    display:flex;
    flex-direction: column;
    gap: .12rem;
    margin: 0;
    padding: .25rem 0 0;
    list-style: none;
}

.sidebar-link{
    display:flex;
    align-items:center;
    padding: .45rem .6rem;
    border-radius: 999px;
    color: var(--app-text-muted);
    font-size: .86rem;
    white-space: nowrap;
    transition: background .12s ease-out, color .12s ease-out, box-shadow .12s ease-out;
}

.sidebar-link:hover{
    background: rgba(0,0,0,.04);
    color: var(--app-text-main);
}

.sidebar-icon{
    width: 22px;
    text-align:center;
    font-size: .95rem;
    color: inherit;
}

.sidebar-label{
    margin-left: .5rem;
    opacity: 0;
    transition: opacity .12s ease-out;
}

.sidebar:hover .sidebar-label{ opacity: 1; }

.sidebar-link.active{
    background: var(--app-accent-soft);
    color: var(--app-text-main);
    box-shadow: inset 0 0 0 1px rgba(0,136,204,.18);
}

/* MAIN */
main{ min-width: 0; padding-top: 1.25rem; }

/* Header row */
.app-main-header{
    display:flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.1rem;
}

.app-main-header h2{
    margin: 0;
    font-size: 1.35rem;
    font-weight: 650;
}

.app-main-header-actions{
    display:flex;
    gap: .6rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn-primary-pill{
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 999px;
    background: linear-gradient(135deg,#60a5fa,#2563eb);
    padding: .45rem 1.05rem;
    color: #fff;
    font-size: .9rem;
    display:inline-block;
    cursor:pointer;
}

.btn-primary-pill:hover{
    filter: brightness(.95);
    color:#fff;
}

.btn-outline-pill {
    border-radius: 999px;
    padding: .45rem 1.2rem;
    font-size: .9rem;
    background: rgba(59,130,246,0.08);
    border: 1px solid rgba(148,163,184,0.6);
    color: #1f2937;
    display: inline-block;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.btn-outline-pill:hover {
    background: rgba(59,130,246,0.16);
    border-color: #3b82f6;
    color: #111827;
}

/* Panels */
.ticket-panel{
    background: var(--app-surface);
    border-radius: 12px;
    border: 1px solid var(--app-border);
    margin-bottom: 1.25rem;
}

.ticket-panel-header{
    padding: .85rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,.08);
    font-size: .95rem;
    font-weight: 650;
    background: var(--app-surface-2);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.ticket-panel-body{
    padding: .95rem 1rem 1.05rem;
    color: var(--app-text-main);
}

/* Ticket tables */
.table-ticket{
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    color: var(--app-text-main);
    font-size: .86rem;
}

.table-ticket th,
.table-ticket td{
    border: 0;
    padding: .6rem .75rem;
    vertical-align: middle;
}

.table-ticket thead th{
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .7rem;
    color: var(--app-text-muted);
    border-bottom: 1px solid rgba(0,0,0,.10);
    background: var(--app-surface-2);
}

.table-ticket tbody tr:nth-child(even){ background: #ffffff; }
.table-ticket tbody tr:nth-child(odd){ background: #fbfcfd; }

.table-ticket tbody tr:hover{
    background: rgba(0,136,204,.06);
}


/* Modern ticket timeline */
.ticket-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.timeline-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline-entry {
    display: flex;
    gap: 0.75rem;
}

.timeline-entry-side {
    width: 90px;
    text-align: right;
    font-size: 0.72rem;
    color: var(--app-text-muted);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding-top: 0.2rem;
}

.timeline-date {
    opacity: 0.85;
}

.timeline-time {
    font-weight: 500;
}

.timeline-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    margin-top: 0.25rem;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}

.timeline-dot--client{ background:#28a745; }
.timeline-dot--support{ background: var(--app-accent); }
.timeline-dot--system{ background:#f0ad4e; }

.timeline-entry-content{
    flex: 1;
    background: #fff;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,.10);
    padding: .7rem .85rem .65rem;
}

.timeline-entry-header{
    display:flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: .3rem;
}

.timeline-author{ font-weight: 650; font-size: .9rem; }
.timeline-role{ font-size: .78rem; color: var(--app-text-muted); }

.timeline-tag{
    font-size: .7rem;
    border-radius: 999px;
    padding: .08rem .45rem;
    border: 1px solid rgba(0,0,0,.14);
    color: var(--app-text-muted);
    white-space: nowrap;
    background: #fff;
}

.timeline-tag--client{ border-color: rgba(40,167,69,.35); color: #1e7e34; }
.timeline-tag--support{ border-color: rgba(0,136,204,.35); color: #006fa8; }
.timeline-tag--system{ border-color: rgba(240,173,78,.45); color: #b06b00; }

.timeline-entry-body{ color: var(--app-text-main); line-height: 1.45; margin-bottom: .35rem; }
.timeline-entry-body p{ margin:0; }

.timeline-entry-footer{ display:flex; justify-content:flex-end; margin-top:.2rem; }
.timeline-entry-footer form{ margin:0; }

.timeline-edit-button{
    margin-top: .35rem;
    padding: .12rem .55rem;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.18);
    background: #fff;
    color: var(--app-text-muted);
    font-size: .72rem;
    line-height: 1.2;
}

.timeline-edit-button:hover{
    border-color: rgba(0,136,204,.35);
    color: var(--app-text-main);
    background: rgba(0,136,204,.06);
}

/* Timeline author blockquotes */
blockquote.b-thick{
    margin: 0;
    padding: .4rem .65rem;
    border-left: 4px solid transparent;
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.25;
    background: #f8fafc;
}

/* Client */
blockquote.b-thick.client{
    border-left-color: #22c55e;
    background: rgba(34,197,94,.10);
    color: #166534;
}

/* Support */
blockquote.b-thick.support{
    border-left-color: var(--app-accent);
    background: rgba(0,136,204,.10);
    color: #003b5c;
}

/* System */
blockquote.b-thick.system{
    border-left-color: #f0ad4e;
    background: rgba(240,173,78,.15);
    color: #7a4a00;
}


/* Ticket files */
.ticket-file{ margin-bottom: 6px; font-size: .88rem; color: var(--app-text-main); }
.ticket-file i{ margin-right: 6px; opacity: .7; color: var(--app-text-muted); }

/* Portal action cards (centered, light theme) */
.portal-actions{
    display:grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: .5rem;
}

@media (max-width: 900px){
    .portal-actions{ grid-template-columns: 1fr; }
}

.action-card{
    background: var(--app-surface);
    border-radius: 16px;
    border: 1px solid var(--app-border);
    padding: 2rem 1.5rem 1.75rem;
    display:flex;
    flex-direction: column;
    align-items:center;
    text-align:center;
}

.action-card:hover{
    border-color: rgba(59,130,246,0.45);
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
}

.action-card-icon{
    width: 72px;
    height: 72px;
    border-radius: 22px;
    margin-bottom: 1rem;
    display:flex;
    align-items:center;
    justify-content:center;
    background: rgba(0,136,204,.10);
    border: 1px solid rgba(0,136,204,.18);
}

.action-card-icon i{
    font-size: 2rem;
    color: var(--app-accent);
}

.action-card-title{
    font-size: 1.1rem;
    font-weight: 650;
    margin-bottom: .4rem;
}

.action-card-text{
    font-size: .92rem;
    color: var(--app-text-muted);
    line-height: 1.45;
    max-width: 34ch;
    margin-bottom: 1.25rem;
}

.action-card-actions{
    display:flex;
    justify-content:center;
}

/* Footer */
.app-shell > footer{
    text-align:center;
    padding: .75rem 0;
    font-size: .75rem;
    color: var(--app-text-muted) !important;
    border-top: 1px solid rgba(0,0,0,.08);
    background: transparent;
}

.app-shell > footer,
.app-shell > footer *{
    color: var(--app-text-muted) !important;
}

/* Responsive tweaks */
@media (max-width: 768px){
    .app-body{
        grid-template-columns: 64px minmax(0, 1fr);
        padding: 0 1rem 1rem 0;
        gap: 1rem;
    }

    .brand-right{ font-size: 1rem; }

    .timeline-entry-side{ display:none; }
}

/* Light info strip (single definition) */
.info-strip{
    display: flex;
    align-items: center;
    gap: .5rem;

    padding: .75rem 1rem;
    margin-bottom: 1.25rem;

    border: 1px solid rgba(0,0,0,.10);
    border-radius: 10px;

    background: #f7f8fa;
    color: var(--app-text-muted);
    font-size: .9rem;
}

.info-strip i{
    color: var(--app-accent);
    opacity: .9;
}

/* Support hours indicator */
.support-hours {
    display: flex;
    align-items: center;
    gap: .75rem;

    padding: .75rem 1rem;
    margin-bottom: 1.25rem;

    border-radius: 10px;
    border: 1px solid rgba(0,0,0,.10);
    background: #f7f8fa;

    font-size: .9rem;
}

.support-hours-icon {
    width: 34px;
    height: 34px;
    border-radius: 999px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(0,0,0,.05);
    color: #555;
    flex-shrink: 0;
}

.support-hours-title {
    font-weight: 600;
    margin-bottom: .1rem;
}

.support-hours-text {
    color: var(--app-text-muted);
    font-size: .85rem;
}

.support-hours-time {
    margin-left: .35rem;
    white-space: nowrap;
}

/* State colouring */
.support-hours--core {
    border-color: rgba(40,167,69,.35);
    background: rgba(40,167,69,.06);
}

.support-hours--core .support-hours-icon {
    color: #28a745;
    background: rgba(40,167,69,.15);
}

.support-hours--extended {
    border-color: rgba(240,173,78,.45);
    background: rgba(240,173,78,.08);
}

.support-hours--extended .support-hours-icon {
    color: #b06b00;
    background: rgba(240,173,78,.18);
}

.support-hours--off {
    border-color: rgba(108,117,125,.35);
    background: rgba(108,117,125,.06);
}

.support-hours--off .support-hours-icon {
    color: #6c757d;
    background: rgba(108,117,125,.18);
}

/* Inline welcome hint */
.welcome-inline {
    margin: .5rem 0 1.25rem;
    font-size: .95rem;
    color: var(--app-text-muted);
}

.welcome-inline strong {
    color: var(--app-text-main);
    font-weight: 600;
    margin-right: .25rem;
}

.welcome-context{
    font-size: .85rem;
    color: #6b7280;
    margin-bottom: .5rem;
}

/* Welcome panel: latest activity row */
.welcome-activity{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin-top:12px;

    padding:10px 12px;
    border:1px solid #e6e9ef;
    border-radius:10px;
    background:#f8fafc;
}

.welcome-activity-left{
    display:flex;
    align-items:center;
    gap:10px;
    min-width:0;
}

.welcome-activity-label{
    display:inline-flex;
    align-items:center;
    gap:6px;
    font-size:.85rem;
    color:#6b7280;
    white-space:nowrap;
}

.welcome-activity-link{
    font-weight:600;
    color:#1f2937;
    text-decoration:none;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    max-width: 620px;
}

.welcome-activity-link:hover{
    text-decoration:underline;
}

.welcome-activity-time{
    font-size:.85rem;
    color:#6b7280;
    white-space:nowrap;
}

@media (max-width: 900px){
    .welcome-activity{
        flex-direction:column;
        align-items:flex-start;
    }
    .welcome-activity-link{
        max-width: 100%;
    }
}

/* Welcome stats (single, final version) */
.welcome-stats{
    display:flex;
    gap:12px;
    flex-wrap:wrap;
}

.welcome-stat{
    position:relative;
    overflow:hidden;
    background:#fff;
    border:1px solid #e6e6e6;
    border-radius:10px;
    padding:14px 16px 12px;
    min-width:140px;
}

.welcome-stat::before{
    content:"";
    position:absolute;
    top:0;
    left:0;
    height:4px;
    width:100%;
    background:#d1d5db;
}

/* per-card colors */
.welcome-stat.stat-open::before{
    background:#22c55e;
}

.welcome-stat.stat-closed::before{
    background:#9ca3af;
}

/* Optional: slight emphasis on open number */
.welcome-stat.stat-open .welcome-stat-value{
    color:#166534;
}

.welcome-stat-value{
    font-size:20px;
    font-weight:700;
    color:#111827;
    line-height:1.1;
    margin-top:6px;
}

.welcome-stat-label{
    font-size:13px;
    color:#6b7280;
    margin-top:4px;
}

/* --- Form styling (client portal) --- */
.app-subtitle {
    color: var(--app-text-muted);
    font-size: .9rem;
    margin-top: .15rem;
}

.form-row { margin-bottom: 1rem; }

.form-label {
    display: block;
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: .4rem;
}

.form-hint {
    margin-top: .35rem;
    font-size: .82rem;
    color: var(--app-text-muted);
}

/* Form inputs: white background, clean SaaS look */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    padding: .6rem .75rem;
    outline: none;
}

.form-select { padding-right: 2.2rem; }

.form-textarea { resize: vertical; min-height: 180px; }

/* Placeholder text */
.form-input::placeholder,
.form-textarea::placeholder {
    color: #9ca3af;
}

/* Focus state */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--app-accent);
    box-shadow: 0 0 0 2px rgba(59,130,246,.15);
    background: #ffffff;
}

/* Disabled */
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background: #f9fafb;
    color: #9ca3af;
}

.form-checkline {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.form-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--app-accent);
}

.form-checklabel {
    margin: 0;
    font-weight: 600;
    font-size: .9rem;
}

.form-actions { margin-top: 1.1rem; }

.btn-block {
    width: 100%;
    text-align: center;
}

.ticket-view-grid{
    display:grid;
    grid-template-columns: 1fr 360px;
    gap: 1.25rem;
    align-items:start;
}

@media (max-width: 900px){
    .ticket-view-grid{
        grid-template-columns: 1fr;
    }
}

/* Summary card on ticket view */
.metric-row{
    display:grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.metric-card{
    background: #fff;
    border: 1px solid rgba(0,0,0,.10);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    display:flex;
    flex-direction:column;
    gap:.35rem;
}

/* internal layout */
.metric-label{
    font-size:.72rem;
    text-transform:uppercase;
    letter-spacing:.08em;
    color: var(--app-text-muted);
}

.metric-main{
    display:flex;
    align-items:center;
    gap:.6rem;
}

.metric-main-icon{
    width:32px;
    height:32px;
    border-radius:8px;
    display:flex;
    align-items:center;
    justify-content:center;
    background: rgba(0,136,204,.10);
    color: var(--app-accent);
    flex-shrink:0;
}

.metric-main-text{
    font-size:.95rem;
    font-weight:600;
    line-height:1.2;
}

.metric-sub{
    font-size:.8rem;
    color: var(--app-text-muted);
}

/* Responsive: stack on small screens */
@media (max-width: 900px){
    .metric-row{
        grid-template-columns: 1fr;
    }
}

/* Accent line on top of card */
.metric-card{
    position: relative;
    overflow: hidden;
}

.metric-accent{
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    width: 100%;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    background: rgba(0,0,0,.10); /* default */
}

.metric-card{
    position: relative;
    overflow: hidden;
}

.metric-accent{
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    width: 100%;
    z-index: 2;
    background: rgba(0,0,0,.10);
}
