:root{
    --bg:#f6f8fc;
    --panel:#ffffff;
    --panel-2:#f4f7ff;
    --muted:#64748b;
    --text:#0f172a;

    --accent:#0ea5e9;
    --accent-2:#16a34a;
    --danger:#dc2626;
    --warn:#d97706;

    --border:rgba(2,6,23,0.08);
    --border-strong:rgba(2,6,23,0.16);
    --shadow:0 10px 25px rgba(2,6,23,0.06);

    --radius:14px;
    --radius-sm:10px;

    --input:#f7f9ff;
}

/* DARK THEME OVERRIDES */
html[data-theme="dark"]{
    --bg:#0b1220;
    --panel:#0f172a;
    --panel-2:#111c33;
    --muted:#94a3b8;
    --text:#e5e7eb;

    --accent:#38bdf8;
    --accent-2:#22c55e;
    --danger:#ef4444;
    --warn:#f59e0b;

    --border:rgba(255,255,255,0.08);
    --border-strong:rgba(255,255,255,0.14);
    --shadow:0 10px 30px rgba(0,0,0,0.25);

    --input:#0b142b;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
    margin:0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, sans-serif;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(14,165,233,0.08), transparent 45%),
        radial-gradient(1200px 700px at 90% 0%, rgba(22,163,74,0.06), transparent 50%),
        var(--bg);
    color:var(--text);
}

html[data-theme="dark"] body{
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(56,189,248,0.10), transparent 45%),
        radial-gradient(1200px 700px at 90% 0%, rgba(34,197,94,0.08), transparent 50%),
        var(--bg);
}

/* Links */
a{color:var(--accent); text-decoration:none}
a:hover{opacity:0.9}
.ticket-link{
    color:var(--text);
    text-decoration:none;
    border-bottom:1px dashed rgba(127,127,127,0.25);
}
.ticket-link:hover{
    border-bottom-color:rgba(127,127,127,0.5);
}

.muted{color:var(--muted); font-size:12px}
.small-input{max-width:120px}

.app-container{
    max-width:1200px;
    margin:0 auto;
    padding:18px 16px 36px;
}

/* Page header */
.page-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin:6px 0 16px;
}
.page-header h1{
    font-size:20px;
    font-weight:650;
    font-variant: small-caps;
    letter-spacing:0.2px;
    margin:0;
}

/* Topbar */
.topbar{
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.92));
    backdrop-filter: blur(10px);
    border-bottom:1px solid var(--border);
}
html[data-theme="dark"] .topbar{
    background: linear-gradient(180deg, rgba(15,23,42,0.98), rgba(15,23,42,0.92));
}

.topbar-inner{
    max-width:1200px;
    margin:0 auto;
    padding:10px 16px;
    display:grid;
    grid-template-columns: 1fr auto 1fr;
    align-items:center;
    gap:12px;
}
.brand{
    display:inline-flex;
    align-items:center;
    gap:10px;
    text-decoration:none;
    color:var(--text);
    font-weight:650;
}
.brand-logo{
    height:50px;
    width:auto;
    object-fit:contain;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.18));
}
.brand-text{
    font-size:13px;
    letter-spacing:0.3px;
    opacity:0.95;
}

.topbar-center{
    display:inline-flex;
    gap:8px;
    align-items:center;
    justify-content:center;
    flex-wrap:wrap;
}
.topbar-pill{
    display:inline-flex;
    align-items:center;
    gap:6px;
    padding:6px 10px;
    border-radius:10px;
    text-decoration:none;
    font-size:12px;
    color:var(--text);
    background: rgba(127,127,127,0.06);
    border:1px solid var(--border);
    transition:0.15s ease;
    opacity:0.85;
}
.topbar-pill:hover{
    background: rgba(127,127,127,0.12);
    opacity:1;
}
.topbar-pill.active{
    background: rgba(127,127,127,0.18);
    border-color: var(--border-strong);
    opacity:1;
}

.topbar-right{
    display:inline-flex;
    justify-content:flex-end;
    gap:8px;
}
.topbar-icon{
    text-decoration:none;
    font-size:16px;
    line-height:1;
    padding:6px 8px;
    border-radius:8px;
    background: rgba(127,127,127,0.06);
    border:1px solid var(--border);
    color: var(--text);
    cursor:pointer;
}
.topbar-icon:hover{
    background: rgba(127,127,127,0.12);
}

/* Status dots in nav */
.dot{
    width:10px;
    height:10px;
    border-radius:999px;
    display:inline-block;
    border:2px solid currentColor;
    background:transparent;
}
.dot-open{color:var(--accent-2)}
.dot-closed{color:var(--danger)}
.dot-pending{color:var(--warn)}
/* Title dots scale with heading text */
.dot-title{
    width: 0.9em;
    height: 0.9em;
    border-width: 0.14em;
    margin: 0 0.35em 0 0.35em;
    vertical-align: -0.08em;
}

.title-sep{
    margin: 0 0.35em;
    opacity: 0.6;
}

/* Cards */
.form-card,
.card{
    background: var(--panel);
    border:1px solid var(--border);
    border-radius: var(--radius);
    padding:14px 14px;
    box-shadow: var(--shadow);
}
.card-compact{padding:10px 12px}

/* Table */
.table-wrapper{
    overflow:auto;
    border-radius: var(--radius);
}
.ticket-table{
    width:100%;
    border-collapse:separate;
    border-spacing:0;
    min-width:780px;
}
.ticket-table thead th{
    position:sticky;
    top:0;
    background: rgba(127,127,127,0.06);
    font-size:11px;
    text-transform:uppercase;
    letter-spacing:0.6px;
    padding:10px 10px;
    border-bottom:1px solid var(--border);
}
.ticket-table tbody td{
    font-size:12.5px;
    padding:10px 10px;
    border-bottom:1px solid rgba(127,127,127,0.10);
    vertical-align:top;
}
.ticket-table tbody tr:hover{
    background: rgba(127,127,127,0.05);
}
.table-empty{
    text-align:center;
    color:var(--muted);
    padding:16px 10px;
}

.sortable-table th{cursor:pointer}

/* Badges */
.badge{
    display:inline-flex;
    align-items:center;
    gap:6px;
    padding:3px 8px;
    border-radius:999px;
    font-size:10.5px;
    border:1px solid var(--border);
    color:var(--text);
    background: rgba(127,127,127,0.08);
}
.badge-open{border-color:rgba(22,163,74,0.35)}
.badge-pending{border-color:rgba(217,119,6,0.35)}
.badge-closed{border-color:rgba(220,38,38,0.35)}

/* Forms */
.form-grid{display:flex; flex-direction:column; gap:14px}
.form-row{display:flex; flex-direction:column; gap:6px}
.form-row-inline{
    display:grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap:12px;
}
.form-label{
    font-size:11px;
    color:var(--muted);
    letter-spacing:0.3px;
}
.form-input,
.form-select,
.form-textarea{
    width:100%;
    background: var(--input);
    border:1px solid var(--border);
    color:var(--text);
    border-radius: var(--radius-sm);
    padding:9px 10px;
    font-size:12.5px;
    outline:none;
    transition: 0.15s ease;
}
.form-textarea{resize:vertical; min-height:90px}
.form-input::placeholder{color:rgba(100,116,139,0.6)}
.form-input:focus,
.form-select:focus,
.form-textarea:focus{
    border-color: rgba(14,165,233,0.45);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.12);
}

.form-select{
    appearance:none;
    background-image:
        linear-gradient(45deg, transparent 50%, rgba(100,116,139,0.7) 50%),
        linear-gradient(135deg, rgba(100,116,139,0.7) 50%, transparent 50%);
    background-position:
        calc(100% - 16px) calc(50% - 2px),
        calc(100% - 11px) calc(50% - 2px);
    background-size:5px 5px, 5px 5px;
    background-repeat:no-repeat;
}

/* Buttons */
.btn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:6px;
    padding:8px 12px;
    border-radius: 10px;
    font-size:12px;
    font-weight:600;
    letter-spacing:0.2px;
    border:1px solid transparent;
    cursor:pointer;
    transition:0.15s ease;
}
.btn-primary{
    background: linear-gradient(135deg, rgba(14,165,233,0.18), rgba(14,165,233,0.06));
    border-color: rgba(14,165,233,0.35);
    color:#0b1220;
}
html[data-theme="dark"] .btn-primary{
    color:#eaf6ff;
    background: linear-gradient(135deg, rgba(56,189,248,0.22), rgba(56,189,248,0.08)), #0b2a45;
    border-color: rgba(56,189,248,0.35);
}
.btn-primary:hover{filter:brightness(1.06)}

.btn-secondary{
    background: rgba(127,127,127,0.08);
    border-color: var(--border);
    color:var(--text);
}
.btn-secondary:hover{background: rgba(127,127,127,0.14)}

.btn-outline{background: transparent}
.btn-ghost{
    background: transparent;
    border-color: var(--border);
    color:var(--text);
    opacity:0.9;
}
.btn-ghost:hover{
    background: rgba(127,127,127,0.08);
    opacity:1;
}
.btn-icon{
    width:28px;
    height:28px;
    padding:0;
    font-size:16px;
    line-height:1;
}
.btn-full{width:100%}

.form-actions{
    display:flex;
    gap:8px;
    justify-content:flex-end;
    margin-top:6px;
}

/* Detail grid */
.detail-grid{
    display:grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap:10px 14px;
}
.detail-row{
    display:flex;
    flex-direction:column;
    gap:4px;
    padding:8px 10px;
    border-radius: 10px;
    background: rgba(127,127,127,0.06);
    border:1px solid rgba(127,127,127,0.08);
}
.detail-label{
    font-size:10px;
    color:var(--muted);
    letter-spacing:0.4px;
    text-transform:uppercase;
}
.detail-value{
    font-size:12.5px;
    color:var(--text);
}

/* TIG toggle + Switch */
.tig-row .tig-options{
    display:flex;
    align-items:center;
    gap:12px;
    flex-wrap:wrap;
}
.radio-inline{
    display:inline-flex;
    align-items:center;
    gap:6px;
    font-size:12px;
    color:var(--text);
}
.tig-toggle{
    display:inline-flex;
    align-items:center;
    gap:8px;
    padding:6px 10px;
    border-radius:999px;
    border:1px solid var(--border);
    background: rgba(127,127,127,0.08);
}
.toggle-label{font-size:10.5px; color:var(--muted)}

.switch{
    position:relative;
    display:inline-block;
    width:36px;
    height:20px;
}
.switch input{opacity:0; width:0; height:0}
.slider{
    position:absolute;
    cursor:pointer;
    inset:0;
    background: rgba(127,127,127,0.25);
    border:1px solid var(--border);
    transition: .2s;
    border-radius: 999px;
}
.slider:before{
    position:absolute;
    content:"";
    height:14px;
    width:14px;
    left:2px;
    top:2px;
    background: #ffffff;
    transition: .2s;
    border-radius: 999px;
}
.switch input:checked + .slider{
    background: rgba(22,163,74,0.25);
    border-color: rgba(22,163,74,0.45);
}
.switch input:checked + .slider:before{
    transform: translateX(16px);
}

/* Dynamic lists */
.dynamic-list{
    display:flex;
    flex-direction:column;
    gap:8px;
    margin-bottom:8px;
}
.dynamic-row{
    display:grid;
    grid-template-columns: 1fr auto auto;
    gap:8px;
    align-items:center;
}

/* Attachments */
.attachment-dropzone{
    border:1px dashed rgba(127,127,127,0.25);
    background: rgba(127,127,127,0.05);
    padding:10px;
    border-radius: 10px;
}
.attachment-previews{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    margin-top:8px;
}
.attachment-chip{
    padding:6px 8px;
    border-radius:10px;
    background: rgba(127,127,127,0.08);
    border:1px solid var(--border);
    font-size:11px;
}

/* Thread */
.thread-list{
    display:flex;
    flex-direction:column;
    gap:10px;
    margin-top:8px;
}
.thread-item{
    border:1px solid rgba(127,127,127,0.12);
    background: rgba(127,127,127,0.05);
    padding:10px;
    border-radius: 12px;
}

/* Ticket view layout */
.ticket-view-layout{
    display:grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap:14px;
    align-items:start;
}
.ticket-log-panel{
    background: transparent;
    border: none;
    padding: 2px 2px 2px 8px;
}
.ticket-log-item{
    padding:8px 0;
    border-bottom:1px dashed rgba(127,127,127,0.18);
}
.ticket-log-item:last-child{border-bottom:none}
.ticket-log-date{
    display:block;
    font-size:10px;
    color:var(--muted);
    margin-bottom:4px;
}

/* Status footer */
.ticket-status-footer{margin-top:10px}
.status-toggle{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}
.status-button{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:8px 12px;
    border-radius: 12px;
    font-size:11.5px;
    font-weight:650;
    border:1px solid var(--border);
    background: rgba(127,127,127,0.08);
    color:var(--text);
    transition:0.15s ease;
}
.status-button:hover{background: rgba(127,127,127,0.14)}
.status-open{border-color: rgba(22,163,74,0.35)}
.status-pending{border-color: rgba(217,119,6,0.35)}
.status-closed{border-color: rgba(220,38,38,0.35)}

/* Login pages */
.login-page{
    min-height:100%;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:24px;
}
.login-card{
    width:min(460px, 100%);
    background: var(--panel);
    border:1px solid var(--border);
    border-radius: var(--radius);
    padding:22px 22px;
    box-shadow: var(--shadow);
}
.login-title{
    font-size:18px;
    margin:0 0 14px;
}
.login-form{display:flex; flex-direction:column; gap:10px}
.login-footer{
    margin-top:14px;
    font-size:11px;
    color:var(--muted);
    text-align:center;
}

/* Settings layout */
.settings-layout{
    display:grid;
    grid-template-columns: 230px minmax(0,1fr);
    gap:14px;
    align-items:start;
}
.settings-sidebar{
    background: var(--panel);
    border:1px solid var(--border);
    border-radius: var(--radius);
    padding:10px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 70px;
}
.settings-link{
    display:block;
    padding:9px 10px;
    border-radius: 10px;
    font-size:12px;
    color:var(--text);
    border:1px solid transparent;
    background: transparent;
    opacity:0.85;
}
.settings-link:hover{
    background: rgba(127,127,127,0.08);
    opacity:1;
}
.settings-link-active{
    background: rgba(127,127,127,0.14);
    border-color: var(--border);
    opacity:1;
}

/* Search input */
.list-search{
    display:flex;
    align-items:center;
    gap:8px;
}
.search-input{
    background: var(--input);
    border:1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding:8px 10px;
    font-size:12px;
    min-width:220px;
}

/* Admin TIG highlight rows - stronger */
.tig-row-pending{
    background: rgba(220,38,38,0.20);
    border-left: 4px solid rgba(220,38,38,0.75);
}
.tig-row-done{
    background: rgba(22,163,74,0.22);
    border-left: 4px solid rgba(22,163,74,0.75);
}

html[data-theme="dark"] .tig-row-pending{
    background: rgba(239,68,68,0.20);
    border-left: 4px solid rgba(239,68,68,0.8);
}
html[data-theme="dark"] .tig-row-done{
    background: rgba(34,197,94,0.22);
    border-left: 4px solid rgba(34,197,94,0.8);
}

/* Responsive */
@media (max-width: 1100px){
    .ticket-view-layout{grid-template-columns: minmax(0,1fr) 280px}
}
@media (max-width: 980px){
    .form-row-inline{grid-template-columns: 1fr 1fr}
    .detail-grid{grid-template-columns: 1fr}
    .settings-layout{grid-template-columns: 200px minmax(0,1fr)}
}
@media (max-width: 820px){
    .topbar-inner{grid-template-columns: 1fr; gap:8px}
    .topbar-right{justify-content:flex-start}
    .ticket-view-layout{grid-template-columns: 1fr}
    .settings-layout{grid-template-columns: 1fr}
    .settings-sidebar{position: static}
}
@media (max-width: 560px){
    .form-row-inline{grid-template-columns: 1fr}
    .dynamic-row{grid-template-columns: 1fr 1fr auto}
    .search-input{min-width: 160px; width: 100%}
}
