:root{
    --navy:#07142e;
    --navy2:#0c2551;
    --blue:#285bf5;
    --blue-soft:#edf2ff;
    --green:#13a865;
    --green-soft:#e9fbf2;
    --purple:#7748ee;
    --purple-soft:#f1ecff;
    --orange:#f29a12;
    --orange-soft:#fff2df;
    --red:#e7494d;
    --red-soft:#fff0f0;
    --text:#172440;
    --muted:#71809a;
    --line:#e4e9f2;
    --bg:#f5f7fb;
    --white:#fff;
    --shadow:0 12px 30px rgba(31,53,95,.06);
}

*{box-sizing:border-box}

body{
    margin:0;
    color:var(--text);
    background:var(--bg);
    font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}

a{text-decoration:none;color:inherit}
button,input,select{font:inherit}

.app-shell{min-height:100vh}

.sidebar{
    position:fixed;
    inset:0 auto 0 0;
    width:255px;
    display:flex;
    flex-direction:column;
    padding:26px 15px;
    color:#fff;
    background:linear-gradient(180deg,var(--navy),var(--navy2));
}

.brand{
    display:flex;
    align-items:center;
    gap:10px;
    padding:0 10px 30px;
    font-size:27px;
    letter-spacing:-1px;
}

.brand-mark{
    width:38px;
    height:38px;
    display:grid;
    place-items:center;
    border-radius:11px;
    font-size:23px;
    background:linear-gradient(135deg,#3169ff,#7544f4);
}

.brand strong span{color:#9eb4ff}

.nav-menu{
    display:grid;
    gap:7px;
}

.nav-item{
    display:flex;
    align-items:center;
    gap:12px;
    padding:13px 14px;
    border-radius:11px;
    color:#d7e1f7;
    font-size:15px;
}

.nav-item span{font-size:21px;line-height:1}

.nav-item:hover,
.nav-item.active{
    color:#fff;
    background:linear-gradient(135deg,#2359e9,#474dfa);
}

.sidebar-bottom{
    display:grid;
    gap:12px;
    margin-top:auto;
}

.admin-card{
    display:flex;
    align-items:center;
    gap:10px;
    padding:12px;
    border:1px solid rgba(255,255,255,.12);
    border-radius:12px;
    background:rgba(255,255,255,.05);
}

.avatar{
    display:grid;
    place-items:center;
    width:37px;
    height:37px;
    border-radius:50%;
    font-size:12px;
    font-weight:800;
    background:linear-gradient(135deg,#2e68ff,#7043f6);
}

.admin-card strong,
.admin-card small{
    display:block;
}

.admin-card small{
    margin-top:3px;
    color:#aebedc;
    font-size:12px;
}

.logout-btn{
    width:100%;
    border:0;
    padding:10px 13px;
    color:#b7c4dc;
    cursor:pointer;
    text-align:left;
    background:transparent;
}

.main-content{
    min-height:100vh;
    margin-left:255px;
    padding:28px 34px 50px;
}

.topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:20px;
    margin-bottom:25px;
}

.topbar h1{
    margin:0;
    font-size:31px;
    letter-spacing:-1.2px;
}

.topbar p{
    margin:5px 0 0;
    color:var(--muted);
}

.topbar-actions{
    display:flex;
    gap:10px;
    align-items:center;
}

.btn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    padding:11px 15px;
    border:1px solid var(--line);
    border-radius:10px;
    font-weight:750;
    cursor:pointer;
    white-space:nowrap;
}

.btn.primary{
    color:#fff;
    border-color:var(--blue);
    background:linear-gradient(135deg,#285ff7,#3653e7);
    box-shadow:0 10px 20px rgba(40,91,245,.2);
}

.btn.secondary{
    color:#30415f;
    background:#fff;
}

.btn.full{width:100%;margin-top:18px}

.flash{
    margin-bottom:18px;
    padding:14px 17px;
    border:1px solid;
    border-radius:11px;
    font-size:14px;
}

.flash.success{
    color:#087849;
    border-color:#bcefd5;
    background:#effdf5;
}

.flash.error{
    color:#a42127;
    border-color:#ffc9cd;
    background:#fff2f2;
}

.flash ul{margin:8px 0 0;padding-left:20px}

.metric-grid{
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:16px;
    margin-bottom:22px;
}

.metric-card{
    display:flex;
    gap:13px;
    min-height:126px;
    padding:20px;
    border:1px solid var(--line);
    border-radius:16px;
    background:var(--white);
    box-shadow:var(--shadow);
}

.metric-icon{
    width:47px;
    height:47px;
    display:grid;
    flex:0 0 auto;
    place-items:center;
    border-radius:13px;
    font-size:23px;
    font-weight:800;
}

.metric-icon.blue{color:var(--blue);background:var(--blue-soft)}
.metric-icon.green{color:var(--green);background:var(--green-soft)}
.metric-icon.purple{color:var(--purple);background:var(--purple-soft)}
.metric-icon.orange{color:var(--orange);background:var(--orange-soft)}

.metric-card span,
.metric-card small{
    display:block;
    color:var(--muted);
    font-size:12px;
}

.metric-card strong{
    display:block;
    margin:4px 0;
    font-size:28px;
    letter-spacing:-1px;
}

.panel,
.form-card,
.summary-card{
    border:1px solid var(--line);
    border-radius:16px;
    background:var(--white);
    box-shadow:var(--shadow);
}

.panel{
    padding:21px;
    margin-bottom:20px;
}

.panel-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:15px;
    margin-bottom:18px;
}

.panel-header h2,
.form-card h2,
.summary-card h2{
    margin:0;
    font-size:18px;
    letter-spacing:-.35px;
}

.panel-header p{
    margin:4px 0 0;
    color:var(--muted);
    font-size:13px;
}

.table-wrap{overflow:auto}

.table-wrap table{
    width:100%;
    min-width:1080px;
    border-collapse:collapse;
}

.table-wrap th{
    padding:12px 10px;
    color:#65728b;
    border-top:1px solid var(--line);
    border-bottom:1px solid var(--line);
    font-size:12px;
    text-align:left;
    white-space:nowrap;
}

.table-wrap td{
    padding:15px 10px;
    border-bottom:1px solid #edf0f6;
    vertical-align:middle;
    font-size:13px;
}

.table-wrap td small{
    display:block;
    margin-top:3px;
    color:var(--muted);
    font-size:11px;
}

.shortcode{color:#2257e8}

.url-cell{
    max-width:200px;
    overflow:hidden;
    color:#697791;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.badge,
.chip,
.status{
    display:inline-flex;
    align-items:center;
    padding:5px 8px;
    border-radius:7px;
    font-size:11px;
    font-weight:750;
    white-space:nowrap;
}

.badge.blue{color:#1954e5;background:#eaf0ff}
.badge.purple{color:#693ce2;background:#f0eaff}
.badge.green{color:#0d9458;background:#e6faef}

.chip{
    margin:2px 2px 2px 0;
    color:#53617b;
    background:#f3f5f9;
}

.chip.provider{
    color:#c32e3d;
    background:#fff0f1;
}

.status.on{color:#0f9458;background:#e8fbf0}
.status.off{color:#647188;background:#eef1f5}

.actions{
    display:flex;
    gap:6px;
}

.actions form{display:inline}

.icon-btn{
    display:grid;
    width:32px;
    height:32px;
    border:1px solid var(--line);
    border-radius:8px;
    color:#2459f5;
    cursor:pointer;
    place-items:center;
    background:#fff;
}

.icon-btn.danger{color:var(--red)}

.empty-state{
    padding:38px!important;
    color:var(--muted);
    text-align:center;
}

.pagination-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    margin-top:17px;
    color:var(--muted);
    font-size:13px;
}

.pagination-row nav svg{width:16px}

.form-layout{
    display:grid;
    grid-template-columns:minmax(0,1fr) 330px;
    gap:20px;
}

.form-main{
    display:grid;
    gap:18px;
}

.form-card{padding:22px}

.form-card h2{margin-bottom:18px}

.form-card h2 em{
    color:var(--muted);
    font-size:13px;
    font-style:normal;
    font-weight:500;
}

.grid-2,
.grid-3,
.grid-4{
    display:grid;
    gap:16px;
}

.grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.grid-4{grid-template-columns:repeat(4,minmax(0,1fr))}

label{
    display:block;
    color:#263552;
    font-size:13px;
    font-weight:750;
}

label em{
    color:var(--muted);
    font-style:normal;
    font-weight:450;
}

input,
select{
    display:block;
    width:100%;
    margin-top:8px;
    padding:11px 12px;
    outline:none;
    color:#1c2943;
    border:1px solid #dce3ef;
    border-radius:9px;
    background:#fff;
}

input:focus,
select:focus{
    border-color:#4e77ff;
    box-shadow:0 0 0 3px #e8eeff;
}

label small,
.form-card p{
    display:block;
    margin-top:6px;
    color:var(--muted);
    font-size:12px;
    font-weight:450;
    line-height:1.45;
}

.preview-url{
    margin-top:8px;
    padding:11px 12px;
    color:#65728a;
    border:1px solid #dce3ef;
    border-radius:9px;
    background:#f8faff;
}

.preview-url span{
    color:#1f57e9;
    font-weight:800;
}

.mode-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:14px;
}

.mode-option{
    display:flex;
    gap:11px;
    padding:16px;
    cursor:pointer;
    border:1px solid #dce3ef;
    border-radius:12px;
}

.mode-option:has(input:checked){
    border-color:#4f76f7;
    background:#f6f8ff;
    box-shadow:0 0 0 2px #e8eeff;
}

.mode-option input{
    width:auto;
    margin:3px 0 0;
}

.mode-option strong{display:block}

.mode-option small{
    margin-top:5px;
    color:var(--muted);
    font-size:12px;
    font-weight:450;
}

.split-card{
    display:grid;
    grid-template-columns:330px 1fr;
    gap:25px;
}

.toggle-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:14px;
    padding:12px 0;
    border-bottom:1px dashed #e2e7f0;
}

.toggle-row:last-child{border-bottom:0}

.toggle-row strong{display:block}

.toggle-row small{
    margin:4px 0 0;
    color:var(--muted);
    font-size:12px;
    font-weight:450;
}

.toggle-row input{
    position:relative;
    width:42px;
    height:23px;
    flex:0 0 auto;
    margin:0;
    cursor:pointer;
    appearance:none;
    border:0;
    border-radius:99px;
    background:#cbd4e3;
}

.toggle-row input:after{
    position:absolute;
    top:3px;
    left:3px;
    width:17px;
    height:17px;
    content:"";
    transition:.2s;
    border-radius:50%;
    background:#fff;
}

.toggle-row input:checked{
    background:var(--green);
}

.toggle-row input:checked:after{
    left:22px;
}

.toggle-row.vertical{
    align-items:flex-start;
    min-height:75px;
}

.select-all-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:14px;
    margin-bottom:12px;
}

.text-btn{
    padding:3px;
    color:#2459f5;
    cursor:pointer;
    border:0;
    background:transparent;
    font-weight:800;
}

.check-inline{
    display:flex;
    align-items:center;
    gap:8px;
    margin-bottom:11px;
}

.check-inline input,
.choice input{
    width:auto;
    margin:0;
}

.check-list{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    max-height:185px;
    padding:4px;
    overflow:auto;
}

.choice{
    display:inline-flex;
    align-items:center;
    gap:6px;
    padding:8px 10px;
    cursor:pointer;
    border:1px solid #e0e6ef;
    border-radius:8px;
    background:#fafbfe;
    font-size:12px;
    font-weight:650;
}

.choice:has(input:checked){
    color:#1e58e9;
    border-color:#b7c8ff;
    background:#edf2ff;
}

.summary-card{
    position:sticky;
    top:22px;
    align-self:start;
    padding:22px;
}

.summary-card h2{margin-bottom:20px}

.summary-step{
    position:relative;
    display:flex;
    gap:12px;
    padding-bottom:24px;
}

.summary-step:after{
    position:absolute;
    top:34px;
    bottom:4px;
    left:16px;
    content:"";
    border-left:1px solid #dbe3f1;
}

.summary-step:last-of-type:after{display:none}

.summary-step > span{
    display:grid;
    width:33px;
    height:33px;
    flex:0 0 auto;
    color:#2459f5;
    border-radius:50%;
    place-items:center;
    background:#eaf0ff;
    font-size:13px;
    font-weight:800;
}

.summary-step.fallback > span{
    color:var(--red);
    background:var(--red-soft);
}

.summary-step strong{
    display:block;
    font-size:13px;
}

.summary-step p{
    margin:5px 0;
    color:var(--muted);
    font-size:12px;
    line-height:1.45;
}

.summary-note{
    padding:14px;
    color:#53637d;
    border-radius:10px;
    background:#eef3ff;
    font-size:12px;
    line-height:1.5;
}

.form-footer{
    display:flex;
    justify-content:flex-end;
    gap:10px;
    margin-top:18px;
}

.analytics-grid{
    display:grid;
    grid-template-columns:1.35fr .9fr .9fr;
    gap:18px;
    align-items:start;
}

.analytics-grid .panel{margin:0}

.bar-chart{
    display:flex;
    align-items:flex-end;
    justify-content:space-around;
    gap:10px;
    height:235px;
    padding:22px 12px 0;
    border-bottom:1px solid #e5eaf3;
    background:
        linear-gradient(to top,
            transparent 24%,
            #f0f3f8 25%,
            transparent 26%,
            transparent 49%,
            #f0f3f8 50%,
            transparent 51%,
            transparent 74%,
            #f0f3f8 75%,
            transparent 76%);
}

.bar-col{
    display:flex;
    align-items:center;
    flex-direction:column;
    justify-content:flex-end;
    gap:7px;
    height:100%;
    color:#64728a;
    font-size:11px;
}

.bar-col strong{
    color:#2559e8;
    font-size:11px;
}

.bar-col i{
    width:27px;
    min-height:9px;
    border-radius:8px 8px 2px 2px;
    background:linear-gradient(#5883ff,#255af5);
}

.donut-panel{text-align:center}

.donut{
    display:grid;
    width:170px;
    height:170px;
    margin:8px auto 20px;
    border-radius:50%;
    place-items:center;
    background:conic-gradient(#265cf5 calc(var(--percent) * 1%),#dce2ed 0);
}

.donut > div{
    display:grid;
    width:117px;
    height:117px;
    align-content:center;
    border-radius:50%;
    place-items:center;
    background:#fff;
}

.donut strong{font-size:24px}

.donut small{
    color:var(--muted);
    font-size:12px;
}

.legend{
    display:grid;
    grid-template-columns:1fr auto;
    gap:8px;
    text-align:left;
    font-size:12px;
}

.dot{
    display:inline-block;
    width:8px;
    height:8px;
    border-radius:50%;
}

.blue-dot{background:#265cf5}
.gray-dot{background:#cfd6e3}

.rank-list{
    display:grid;
    gap:13px;
}

.rank-list > div{
    display:grid;
    grid-template-columns:80px 1fr 40px;
    align-items:center;
    gap:8px;
    font-size:12px;
}

.rank-list i{
    height:9px;
    overflow:hidden;
    border-radius:20px;
    background:#edf0f5;
}

.rank-list b{
    display:block;
    height:100%;
    border-radius:inherit;
    background:linear-gradient(90deg,#5d84ff,#2459f5);
}

.provider-rank b{
    background:linear-gradient(90deg,#ff8cac,#ed426b);
}

.redirect-summary{
    display:grid;
    gap:17px;
    padding-top:22px;
}

.redirect-summary > div{
    display:flex;
    align-items:center;
    justify-content:space-between;
}

.redirect-summary strong{font-size:24px}

.insight-panel{
    background:linear-gradient(145deg,#fbfcff,#f1f5ff);
}

.insight{
    display:flex;
    gap:10px;
    padding:14px 0;
    border-bottom:1px solid #e2e8f3;
}

.insight:last-child{border-bottom:0}

.insight > span{
    display:grid;
    width:34px;
    height:34px;
    flex:0 0 auto;
    color:#2459f5;
    border-radius:50%;
    place-items:center;
    background:#e7efff;
}

.insight strong{font-size:13px}

.insight p{
    margin:4px 0 0;
    color:var(--muted);
    font-size:12px;
}

.analytics-table{margin-top:20px}

.settings-grid{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:18px;
    align-items:start;
}

.settings-grid .form-card{margin:0}

.settings-list{
    display:grid;
    gap:13px;
}

.settings-list > label{
    display:grid;
    grid-template-columns:145px 1fr;
    align-items:center;
    gap:10px;
}

.settings-list > label input,
.settings-list > label select{
    margin:0;
}

.wide-setting{grid-column:span 2}
.test-card{grid-row:span 2}

.test-result{
    margin-top:16px;
    overflow:hidden;
    border:1px solid var(--line);
    border-radius:11px;
}

.test-result div{
    display:flex;
    justify-content:space-between;
    padding:13px;
    border-bottom:1px solid var(--line);
    font-size:13px;
}

.test-result div:last-child{border-bottom:0}

.test-result span{color:var(--muted)}
.green-text{color:var(--green)}
.muted{color:var(--muted)!important;font-size:12px}

.login-page{
    display:grid;
    min-height:100vh;
    place-items:center;
    background:
        radial-gradient(circle at top right,#edf1ff,transparent 35%),
        #f5f7fb;
}

.login-card{
    width:min(420px,calc(100% - 36px));
    padding:34px;
    border:1px solid var(--line);
    border-radius:18px;
    background:#fff;
    box-shadow:0 25px 70px rgba(26,42,76,.12);
}

.login-brand{
    margin-bottom:30px;
    color:#17233e;
    font-size:27px;
    font-weight:850;
    letter-spacing:-1px;
}

.login-brand > span:first-child{
    display:inline-grid;
    width:36px;
    height:36px;
    margin-right:7px;
    color:#fff;
    border-radius:10px;
    place-items:center;
    background:#285cf5;
}

.login-brand > span:last-child{color:#426af4}

.login-card h1{
    margin:0;
    font-size:25px;
}

.login-card p{
    margin:6px 0 22px;
    color:var(--muted);
}

.field-error{
    display:block;
    margin-top:7px;
    color:#d92d32;
}

.login-note{
    margin-top:20px;
    padding:12px;
    color:#5d6b84;
    border-radius:10px;
    background:#f3f6ff;
    font-size:12px;
    line-height:1.5;
}

@media(max-width:1250px){
    .metric-grid{grid-template-columns:repeat(2,1fr)}
    .form-layout{grid-template-columns:1fr}
    .summary-card{position:static}
    .analytics-grid{grid-template-columns:1fr 1fr}
    .insight-panel{grid-column:span 2}
    .settings-grid{grid-template-columns:1fr 1fr}
    .test-card{grid-row:auto}
}

@media(max-width:900px){
    .sidebar{
        position:static;
        width:100%;
        min-height:auto;
        padding:15px;
    }

    .nav-menu{
        display:flex;
        overflow:auto;
        gap:7px;
    }

    .nav-item{white-space:nowrap}

    .sidebar-bottom{display:none}

    .main-content{
        margin-left:0;
        padding:20px;
    }

    .split-card,
    .grid-3,
    .grid-4{
        grid-template-columns:1fr 1fr;
    }

    .settings-grid{grid-template-columns:1fr}
    .wide-setting{grid-column:auto}
}

@media(max-width:620px){
    .main-content{padding:16px}

    .topbar{
        align-items:flex-start;
        flex-direction:column;
    }

    .topbar h1{font-size:25px}

    .metric-grid,
    .grid-2,
    .grid-3,
    .grid-4,
    .mode-grid,
    .analytics-grid{
        grid-template-columns:1fr;
    }

    .split-card{grid-template-columns:1fr}
    .insight-panel{grid-column:auto}

    .pagination-row{
        display:block;
    }

    .pagination-row nav{
        margin-top:10px;
    }
}

.province-list{
    display:grid;
    gap:10px;
    max-height:430px;
    overflow:auto;
    padding:4px;
}

.province-group{
    border:1px solid #e0e6ef;
    border-radius:10px;
    background:#fbfcff;
}

.province-group summary{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    cursor:pointer;
    padding:11px 13px;
    color:#263552;
    font-size:13px;
    list-style:none;
}

.province-group summary::-webkit-details-marker{
    display:none;
}

.province-group summary::after{
    content:"⌄";
    color:#73819b;
    font-size:16px;
    transition:.2s;
}

.province-group[open] summary::after{
    transform:rotate(180deg);
}

.province-group summary span{
    color:#71809a;
    font-size:11px;
    font-weight:600;
}

.province-group .check-list{
    max-height:none;
    padding:0 12px 13px;
}

.domains-layout{
    display:grid;
    grid-template-columns:380px minmax(0,1fr);
    gap:20px;
}

.domain-add-form{
    display:flex;
    gap:10px;
    margin-top:16px;
}

.domain-add-form input{
    margin:0;
}

.domain-guide{
    margin-top:20px;
    padding:14px;
    border-radius:10px;
    color:#5d6b83;
    background:#f2f5fb;
    font-size:13px;
    line-height:1.6;
}

.domain-guide ol{
    margin:8px 0 0;
    padding-left:20px;
}

@media(max-width:900px){
    .domains-layout{
        grid-template-columns:1fr;
    }

    .domain-add-form{
        flex-direction:column;
    }
}
