/* SelfSurvAI admin dashboard */

:root{
    --navy: #0B2545;
    --ocean: #13315C;
    --teal: #2CA6A4;
    --teal-hover: #23918F;
    --bg: #F4F7FA;
    --card: #FFFFFF;
    --border: #E3E9F0;
    --text: #1B2733;
    --muted: #6B7A8D;
    --input-border: #CBD6E2;
    --danger: #C62828;
    --sidebar-w: 230px;
}

*{ box-sizing: border-box; }

html, body{ margin: 0; padding: 0; }

body{
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a{ color: var(--teal); text-decoration: none; }
a:hover{ color: var(--teal-hover); }

h1, h2, h3{ color: var(--navy); margin: 0; }

/* ---- Sidebar ---------------------------------------------------------- */

.sidebar{
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--navy);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.brand{
    padding: 22px 18px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.brand a{
    color: #fff;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.02em;
}

.brand a:hover{ color: #fff; }

.brand a span{ color: var(--teal); }

.brand-sub{
    color: rgba(255,255,255,.45);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .09em;
}

.env-badge{
    background: #F4B740;
    color: #4A3200;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    padding: 2px 7px;
    border-radius: 999px;
}

.sidebar nav{
    padding: 14px 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
}

.sidebar nav a{
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 18px;
    color: rgba(255,255,255,.7);
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: color .12s, background .12s;
}

.sidebar nav a svg{ width: 17px; height: 17px; flex: none; opacity: .85; }

.sidebar nav a:hover{
    color: #fff;
    background: rgba(255,255,255,.04);
}

.sidebar nav a.active{
    color: #fff;
    border-left-color: var(--teal);
    background: rgba(255,255,255,.06);
}

.sidebar nav a.nav-reset{
    margin-top: auto;
    color: #F4B740;
}

.sidebar nav a.nav-reset:hover{ color: #ffd27a; }

.sidebar nav a.nav-logout{ color: rgba(255,255,255,.55); margin-top: auto; }

.sidebar nav a.nav-reset + a.nav-logout{ margin-top: 0; }

.sidebar nav a.nav-logout:hover{ color: #fff; }

/* ---- Layout ------------------------------------------------------------ */

.main{ margin-left: var(--sidebar-w); }

.content{
    max-width: 1100px;
    padding: 28px;
    margin: 0 auto;
}

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

.topbar h1{ font-size: 22px; font-weight: 700; letter-spacing: -.01em; }

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

.who-avatar{
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--ocean);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: .03em;
}

.who-name{ font-weight: 600; color: var(--text); }

/* ---- Cards ------------------------------------------------------------- */

.card{
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16,35,61,.06);
    padding: 20px 22px;
    margin-bottom: 20px;
}

.card.flush{ padding: 0; overflow: hidden; }

.card h2{
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 14px;
}

.card.flush h2{ padding: 16px 20px 0; margin-bottom: 10px; }

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

.card-head h2{ margin: 0; }

.grid-2{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

/* ---- Stat cards -------------------------------------------------------- */

.stats{
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat{
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16,35,61,.06);
    padding: 16px 18px;
}

.stat .label{
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}

.stat .num{
    font-size: 28px;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.2;
    margin-top: 4px;
}

.stat .sub{
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.stat .breakdown{
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 7px;
    font-size: 12px;
    color: var(--muted);
}

.stat .breakdown span{ white-space: nowrap; }

.dot{
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: baseline;
}

.dot-pending{ background: #5A6B7F; }
.dot-in_progress{ background: #1565C0; }
.dot-submitted{ background: #5E35B1; }
.dot-processing{ background: #B26A00; }
.dot-complete{ background: #2E7D32; }
.dot-failed{ background: #C62828; }

/* ---- Tables ------------------------------------------------------------ */

table{
    width: 100%;
    border-collapse: collapse;
}

th{
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td{
    font-size: 14px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.card.flush th:first-child, .card.flush td:first-child{ padding-left: 20px; }
.card.flush th:last-child, .card.flush td:last-child{ padding-right: 20px; }

tbody tr:hover{ background: #F8FAFC; }

tbody tr:last-child td{ border-bottom: 0; }

td .cell-sub{
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 1px;
}

td.num-cell{ text-align: right; font-variant-numeric: tabular-nums; }
th.num-cell{ text-align: right; }

.empty-state{
    padding: 34px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

/* ---- Status chips ------------------------------------------------------ */

.chip{
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.chip-pending{ background: #EEF2F7; color: #5A6B7F; }
.chip-in_progress{ background: #E3F2FD; color: #1565C0; }
.chip-submitted{ background: #EDE7F6; color: #5E35B1; }
.chip-processing{ background: #FFF3E0; color: #B26A00; }
.chip-complete, .chip-approved, .chip-active{ background: #E8F5E9; color: #2E7D32; }
.chip-failed, .chip-rejected{ background: #FFEBEE; color: #C62828; }
.chip-disabled, .chip-archived{ background: #EEF2F7; color: #5A6B7F; }

/* ---- Buttons ----------------------------------------------------------- */

.btn{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
    text-decoration: none;
}

.btn-primary{ background: var(--teal); color: #fff; }
.btn-primary:hover{ background: var(--teal-hover); color: #fff; }

.btn-secondary{ background: #fff; color: var(--text); border-color: var(--input-border); }
.btn-secondary:hover{ background: #F8FAFC; color: var(--text); }

.btn-danger{ background: var(--danger); color: #fff; }
.btn-danger:hover{ background: #A82121; color: #fff; }

.btn-sm{ padding: 6px 11px; font-size: 13px; border-radius: 7px; }

.btn-block{ width: 100%; }

/* ---- Forms ------------------------------------------------------------- */

label{
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 5px;
}

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=search], select, textarea{
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    padding: 9px 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    outline: none;
    transition: border-color .12s, box-shadow .12s;
}

input:focus, select:focus, textarea:focus{
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(44,166,164,.18);
}

textarea{ resize: vertical; min-height: 64px; }

select{
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7A8D' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 32px;
}

.field{ margin-bottom: 14px; }

.field .hint{
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
    margin: 5px 0 0;
}

.field-row{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-actions{
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}

/* ---- Flash / banners --------------------------------------------------- */

.flash{
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.flash-success{ background: #E8F5E9; color: #2E7D32; border-color: rgba(46,125,50,.22); }
.flash-danger{ background: #FFEBEE; color: #C62828; border-color: rgba(198,40,40,.22); }

.dev-hint{
    background: #FFF8E1;
    border: 1px solid #F0E2AE;
    color: #7A5D00;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-top: 16px;
}

.dev-hint code{
    background: rgba(255,255,255,.7);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
}

/* ---- Filter tabs / bar ------------------------------------------------- */

.tabs{
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.tab{
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    border: 1px solid transparent;
    transition: background .12s, color .12s;
}

.tab:hover{ background: rgba(255,255,255,.75); color: var(--text); }

.tab.active{
    background: #fff;
    color: var(--navy);
    border-color: var(--border);
    box-shadow: 0 1px 2px rgba(16,35,61,.06);
}

.tab .count{
    background: #EEF2F7;
    color: #5A6B7F;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
}

.tab.active .count{ background: rgba(44,166,164,.14); color: var(--teal-hover); }

.filter-bar{
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.filter-bar select{ width: auto; min-width: 200px; }
.filter-bar input[type=search]{ width: 230px; }

/* ---- Request view ------------------------------------------------------ */

.req-header{
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.req-header h2{ font-size: 18px; margin: 0 0 6px; }

.req-meta{
    display: flex;
    flex-wrap: wrap;
    gap: 4px 22px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--muted);
}

.req-meta b{ color: var(--text); font-weight: 600; }

.info-card h2{
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 10px;
}

.info-card .big{ font-size: 15px; font-weight: 700; color: var(--navy); }

.info-card .line{ font-size: 13px; color: var(--muted); margin-top: 2px; }

.req-item{
    display: flex;
    gap: 18px;
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
}

.req-item:first-child{ padding-top: 4px; }
.req-item:last-child{ border-bottom: 0; padding-bottom: 4px; }

.req-item .thumb{ flex: none; }

.req-item .thumb img{
    display: block;
    width: 180px;
    max-width: 180px;
    height: 135px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #F8FAFC;
}

.req-item .no-photo{
    width: 180px;
    height: 135px;
    border-radius: 8px;
    border: 1px dashed var(--input-border);
    background: #F8FAFC;
    color: var(--muted);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.req-item .body{ flex: 1; min-width: 0; }

.req-item .item-title{
    font-size: 14px;
    font-weight: 700;
    color: var(--navy);
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.type-tag{
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    background: #EEF2F7;
    border-radius: 5px;
    padding: 2px 7px;
}

/* Item source: anchor (the asset type's first photo), broker request, AI-built */
.source-tag{
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-radius: 5px;
    padding: 2px 7px;
    white-space: nowrap;
}

.source-anchor{ background: rgba(44,166,164,.14); color: #1D7C7A; }
.source-broker{ background: #EDE7F6; color: #5E35B1; }
.source-ai{ background: #EEF2F7; color: #5A6B7F; }

.note-info{
    background: #E3F2FD;
    border: 1px solid rgba(21,101,192,.22);
    color: #1565C0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}

.req-item .instructions{
    font-size: 13px;
    color: var(--muted);
    margin-top: 3px;
}

.req-item .ai-feedback{
    font-size: 13px;
    color: var(--text);
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 9px;
}

.req-item .answer{
    font-size: 14px;
    color: var(--text);
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 9px;
    white-space: pre-wrap;
}

.req-item .answer.empty{ color: var(--muted); }

/* ---- Danger zone ------------------------------------------------------- */

.danger-zone{
    border-color: #F2C4C4;
}

.danger-zone h2{ color: var(--danger); }

.danger-zone p{ color: var(--muted); font-size: 13px; margin: 0 0 14px; }

/* ---- Items editor ------------------------------------------------------ */

.items-editor{ margin-bottom: 12px; }

.item-row{
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #FBFCFE;
    padding: 14px 16px;
    margin-bottom: 10px;
}

.item-row-head{
    display: flex;
    gap: 10px;
    align-items: center;
}

.item-num{
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.item-row-head select{ width: 128px; flex: none; }
.item-row-head input{ flex: 1; }

.item-actions{ display: flex; gap: 5px; flex: none; }

.icon-btn{
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--input-border);
    border-radius: 7px;
    color: var(--muted);
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}

.icon-btn svg{ width: 14px; height: 14px; }

.icon-btn:hover{ background: #F8FAFC; color: var(--navy); }

.icon-btn.danger:hover{ background: #FFEBEE; color: var(--danger); border-color: #F2C4C4; }

.item-row-body{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.item-row-body label{ font-size: 12px; }

.item-row-body textarea{ min-height: 58px; font-size: 13px; }

.item-row-body .hint{
    font-size: 11.5px;
    color: var(--muted);
    margin: 4px 0 0;
}

.item-row.type-question .ai-wrap{ display: none; }

.item-row.type-question .item-row-body{ grid-template-columns: 1fr; }

/* ---- Auth (login) ------------------------------------------------------ */

.auth-wrap{
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(900px 420px at 85% -10%, rgba(44,166,164,.10), transparent 60%),
        radial-gradient(700px 420px at -10% 110%, rgba(11,37,69,.08), transparent 55%),
        var(--bg);
}

.auth-brand{
    font-size: 26px;
    font-weight: 800;
    color: var(--navy);
    letter-spacing: -.02em;
    margin-bottom: 6px;
}

.auth-brand span{ color: var(--teal); }

.auth-sub{
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 24px;
}

.auth-card{
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16,35,61,.06), 0 12px 32px rgba(16,35,61,.07);
    padding: 28px;
}

.auth-card h1{
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 18px;
}

.auth-hint{ width: 100%; max-width: 380px; }

/* ---- Responsive -------------------------------------------------------- */

@media (max-width: 900px){
    .stats{ grid-template-columns: repeat(2, 1fr); }
    .grid-2{ grid-template-columns: 1fr; }
    .item-row-body{ grid-template-columns: 1fr; }
}

@media (max-width: 760px){
    .sidebar{
        position: static;
        width: auto;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }
    .brand{ border-bottom: 0; padding: 14px 16px; flex: none; }
    .sidebar nav{ flex-direction: row; padding: 0 8px; }
    .sidebar nav a{ border-left: 0; border-bottom: 3px solid transparent; padding: 14px 10px; white-space: nowrap; }
    .sidebar nav a.active{ border-bottom-color: var(--teal); }
    .sidebar nav a.nav-reset{ margin-top: 0; }
    .main{ margin-left: 0; }
    .content{ padding: 18px; }
    .req-item{ flex-direction: column; }
    .table-scroll{ overflow-x: auto; }
}

.chip-skipped{ background:#FFF3E0; color:#B26A00; }
.chip-unclear{ background:#FFF3E0; color:#B26A00; }

.row-actions{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.check-row{ display:flex; align-items:center; gap:9px; margin:0 0 16px; font-size:14px; color:#1B2733; }
.check-row input{ width:17px; height:17px; }

.nav-reset-form{ margin:0; }
button.nav-reset{ width:100%; background:none; border:none; font:inherit; text-align:left; cursor:pointer; }
