/* =========================================================
   ProUPData — Design System
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #eceff5;
    --content-bg: #f6f8fb;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --border: #e8ecf3;
    --border-strong: #d8deea;
    --text: #111726;
    --text-soft: #46506a;
    --text-muted: #8a93a8;

    --primary: #4f46e5;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;

    --success: #16a34a; --success-50: #ecfdf3; --success-100: #d1fadf; --success-700: #15803d;
    --warning: #d97706; --warning-50: #fff8ec; --warning-100: #fdedc8; --warning-700: #b45309;
    --danger:  #dc2626; --danger-50:  #fef2f2; --danger-100:  #fde0e0; --danger-700:  #b91c1c;
    --info:    #2563eb; --info-50:    #eff5ff; --info-100:    #dbe7fe;

    --radius: 16px;
    --radius-sm: 11px;
    --shadow-sm: 0 1px 2px rgba(17,23,38,.05), 0 1px 3px rgba(17,23,38,.04);
    --shadow: 0 6px 20px rgba(17,23,38,.07);
    --shadow-lg: 0 14px 40px rgba(17,23,38,.13);
    --sidebar-w: 264px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    background: var(--content-bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; }

/* ===== App shell ===== */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: linear-gradient(185deg, #131a2c 0%, #0d1322 100%);
    color: #cdd5e6;
    border-right: 1px solid rgba(255,255,255,.05);
}
.brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 22px 20px;
}
.brand-logo {
    width: 42px; height: 42px; flex: none;
    display: grid; place-items: center;
    border-radius: 12px;
    background: linear-gradient(160deg, #6366f1, #4f46e5);
    color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.45);
}
.brand-name { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.brand-sub { font-size: 11.5px; color: #7e89a3; letter-spacing: .6px; text-transform: uppercase; }

.nav { padding: 8px 14px; display: flex; flex-direction: column; gap: 3px; }
.nav-label {
    font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
    color: #5f6b85; padding: 14px 12px 6px; font-weight: 600;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    color: #aeb8cf; font-size: 14.5px; font-weight: 500;
    transition: .15s; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav-item.active {
    background: linear-gradient(90deg, rgba(99,102,241,.22), rgba(99,102,241,.07));
    color: #fff;
}
.nav-item.active::before {
    content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px;
    width: 3px; border-radius: 0 3px 3px 0; background: #818cf8;
}
.nav-item.active svg { opacity: 1; color: #a5b4fc; }

.sidebar-foot { margin-top: auto; padding: 16px 16px 18px; border-top: 1px solid rgba(255,255,255,.06); }
.user { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.avatar {
    width: 38px; height: 38px; flex: none; border-radius: 11px;
    display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 16px;
    background: linear-gradient(160deg, #34d399, #10b981);
}
.user-name { font-size: 14px; font-weight: 600; color: #fff; line-height: 1.3; }
.user-role { font-size: 11.5px; color: #7e89a3; }
.btn-logout {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 9px; border-radius: 10px;
    background: rgba(255,255,255,.05); color: #cdd5e6;
    font-size: 13.5px; font-weight: 500; transition: .15s;
}
.btn-logout:hover { background: rgba(239,68,68,.16); color: #fecaca; text-decoration: none; }
.btn-logout svg { width: 17px; height: 17px; }

.sidebar-backdrop {
    display: none; position: fixed; inset: 0; z-index: 40;
    background: rgba(11,17,32,.5); backdrop-filter: blur(2px);
}

/* ===== Main ===== */
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 14px;
    padding: 16px 30px;
    background: rgba(246,248,251,.85);
    backdrop-filter: saturate(140%) blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-titles h1 { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.25; }
.topbar-titles p { font-size: 13px; color: var(--text-muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.icon-btn {
    display: none; width: 40px; height: 40px; flex: none;
    border: 1px solid var(--border-strong); background: var(--surface);
    border-radius: 10px; cursor: pointer; color: var(--text-soft);
    align-items: center; justify-content: center;
}
.menu-toggle { }
.content { padding: 28px 30px 60px; max-width: 1080px; width: 100%; animation: rise .28s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== Cards ===== */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 26px; margin-bottom: 22px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head .ic {
    width: 40px; height: 40px; flex: none; border-radius: 11px;
    display: grid; place-items: center; background: var(--primary-50); color: var(--primary);
}
.card-head .ic svg { width: 21px; height: 21px; }
.card-title { font-size: 17px; font-weight: 700; color: var(--text); }
.card-desc { font-size: 13px; color: var(--text-muted); margin-top: 1px; }

/* ===== Callout / steps ===== */
.callout {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--primary-50); border: 1px solid var(--primary-100);
    color: #3730a3; border-radius: 12px; padding: 13px 16px;
    font-size: 13.5px; line-height: 1.65; margin-bottom: 20px;
}
.callout svg { width: 19px; height: 19px; flex: none; margin-top: 2px; color: var(--primary); }
.callout b { font-weight: 700; }

/* ===== Forms ===== */
.field { margin-bottom: 18px; }
.field-label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.input {
    width: 100%; padding: 11px 14px; font: inherit; font-size: 14px;
    color: var(--text); background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: 11px;
    transition: border-color .15s, box-shadow .15s;
}
select.input {
    appearance: none; cursor: pointer; padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238a93a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 13px center;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.input::placeholder { color: var(--text-muted); }
.input:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }
.field-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== Option (radio/checkbox cards) ===== */
.option {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 13px 15px; border: 1px solid var(--border); border-radius: 12px;
    cursor: pointer; transition: .15s; background: var(--surface); margin-bottom: 10px;
}
.option:hover { border-color: var(--border-strong); background: var(--surface-2); }
.option input { margin-top: 2px; width: 18px; height: 18px; flex: none; accent-color: var(--primary); cursor: pointer; }
.option-title { font-weight: 600; font-size: 14px; color: var(--text); }
.option-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }
.option:has(input:checked) { border-color: var(--primary); background: var(--primary-50); box-shadow: inset 0 0 0 1px var(--primary); }

/* ===== Dropzone (file) ===== */
.dropzone {
    position: relative; display: block; text-align: center;
    border: 1.6px dashed var(--border-strong); border-radius: 14px;
    padding: 26px 20px; background: var(--surface-2); cursor: pointer; transition: .15s;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-50); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone .dz-ic { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-100); color: var(--primary); }
.dropzone .dz-ic svg { width: 23px; height: 23px; }
.dropzone-text { font-size: 14px; color: var(--text-soft); }
.dropzone-text b { color: var(--primary); font-weight: 700; }
.dropzone-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.dropzone-file { display: none; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--success-700); }
.dropzone.has-file { border-color: var(--success); background: var(--success-50); }
.dropzone.has-file .dropzone-file { display: block; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid transparent; border-radius: 11px; font: inherit;
    font-weight: 600; font-size: 14.5px; padding: 11px 22px; cursor: pointer;
    transition: filter .15s, background .15s, transform .05s, box-shadow .15s; line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: linear-gradient(180deg, #6366f1, #4f46e5); color: #fff; box-shadow: 0 2px 6px rgba(79,70,229,.35); }
.btn-primary:hover { background: linear-gradient(180deg, #4f46e5, #4338ca); }
.btn-success { background: linear-gradient(180deg, #22c55e, #16a34a); color: #fff; box-shadow: 0 2px 6px rgba(22,163,74,.3); }
.btn-success:hover { filter: brightness(.97); }
.btn-danger { background: linear-gradient(180deg, #ef4444, #dc2626); color: #fff; box-shadow: 0 2px 6px rgba(220,38,38,.28); }
.btn-danger:hover { filter: brightness(.97); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn:disabled, .btn.is-loading { opacity: .7; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.spinner {
    width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.45); border-top-color: #fff;
    animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Alerts ===== */
.alert {
    display: flex; gap: 11px; align-items: flex-start;
    padding: 13px 16px; border-radius: 12px; font-size: 14px;
    border: 1px solid; margin-bottom: 18px; line-height: 1.6;
}
.alert svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.alert b { font-weight: 700; }
.alert-success { background: var(--success-50); border-color: var(--success-100); color: var(--success-700); }
.alert-error   { background: var(--danger-50);  border-color: var(--danger-100);  color: var(--danger-700); }
.alert-warning { background: var(--warning-50); border-color: var(--warning-100); color: var(--warning-700); }
.alert-info    { background: var(--info-50);    border-color: var(--info-100);    color: #1d4ed8; }

/* ===== Connection chip ===== */
.conn { display: inline-flex; align-items: center; gap: 9px; padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 500; border: 1px solid; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn-ok { background: var(--success-50); border-color: var(--success-100); color: var(--success-700); }
.conn-bad { background: var(--danger-50); border-color: var(--danger-100); color: var(--danger-700); }
.conn b { font-weight: 700; }
.conn-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 22px; font-size: 13px; color: var(--text-muted); }
.conn-meta span b { color: var(--text-soft); font-weight: 600; }

/* ===== Tabs (pills) ===== */
.tabs {
    display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 5px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 13px; box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.tab {
    display: inline-flex; align-items: center; gap: 8px;
    border: none; background: transparent; color: var(--text-soft);
    font: inherit; font-weight: 600; font-size: 14px; padding: 9px 17px;
    border-radius: 9px; cursor: pointer; transition: .15s;
}
.tab svg { width: 17px; height: 17px; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(79,70,229,.35); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===== Stats ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 14px; margin: 4px 0 4px; }
.stat {
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 13px; padding: 16px 16px 16px 19px;
}
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.stat-num { font-size: 27px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.stat-lbl { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.stat.green::before { background: var(--success); } .stat.green .stat-num { color: var(--success-700); }
.stat.amber::before { background: var(--warning); } .stat.amber .stat-num { color: var(--warning-700); }
.stat.red::before   { background: var(--danger); }  .stat.red .stat-num   { color: var(--danger-700); }
.stat.indigo::before{ background: var(--primary); } .stat.indigo .stat-num{ color: var(--primary-700); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 13px; margin-top: 14px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
    text-align: left; color: var(--text-muted); font-size: 11.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em; padding: 11px 14px;
    background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table .mono { font-family: 'JetBrains Mono', Consolas, monospace; font-size: 12px; color: var(--text); word-break: break-all; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; line-height: 1.5; }
.badge-ok { background: var(--success-100); color: var(--success-700); }
.badge-warn { background: var(--warning-100); color: var(--warning-700); }
.badge-bad { background: var(--danger-100); color: var(--danger-700); }
.badge-info { background: var(--info-100); color: #1d4ed8; }
.badge-neutral { background: #eceef3; color: #5b6478; }

/* ===== Details ===== */
details { margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
summary {
    cursor: pointer; font-size: 14px; color: var(--text); font-weight: 600;
    padding: 13px 16px; background: var(--surface-2); list-style: none;
    display: flex; align-items: center; gap: 8px;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: '▸'; color: var(--text-muted); transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }
details > .table-wrap { border: none; border-top: 1px solid var(--border); border-radius: 0; margin-top: 0; }
details > .field-hint { padding: 10px 16px; }

/* ===== File list ===== */
.filerow { display: flex; align-items: center; gap: 12px; }
.filerow .fic { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--info-50); color: var(--info); }
.filerow .fic svg { width: 18px; height: 18px; }

/* ===== Auth (login) ===== */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: linear-gradient(160deg, #10182b 0%, #0d1322 60%, #131a2c 100%);
}
.auth-card {
    width: 100%; max-width: 410px; background: var(--surface);
    border-radius: 20px; box-shadow: var(--shadow-lg); padding: 36px 34px;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 22px; }
.auth-brand .brand-logo { width: 54px; height: 54px; border-radius: 15px; margin-bottom: 14px; }
.auth-brand h1 { font-size: 21px; font-weight: 800; color: var(--text); }
.auth-brand p { font-size: 13.5px; color: var(--text-muted); margin-top: 3px; }
.auth-card .field-label { font-size: 13px; }
.auth-card .btn { width: 100%; margin-top: 8px; padding: 12px; font-size: 15px; }
.auth-foot { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 20px; }

.muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.section-gap { margin-top: 26px; }

/* ===== Profile switcher (topbar) ===== */
.profile-switch {
    display: flex; align-items: center; gap: 7px;
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: 11px; padding: 5px 7px 5px 11px; box-shadow: var(--shadow-sm);
}
.profile-switch .ps-ic { color: var(--text-muted); display: flex; }
.profile-switch .ps-ic svg { width: 17px; height: 17px; }
.profile-switch select {
    border: none; background: transparent; font: inherit; font-size: 13.5px;
    font-weight: 600; color: var(--text); cursor: pointer; max-width: 220px;
    padding: 4px 26px 4px 2px; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238a93a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 2px center;
}
.profile-switch select:focus { outline: none; }

/* ===== Profile cards (settings) ===== */
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.profile-card {
    border: 1px solid var(--border); border-radius: 14px; padding: 16px;
    background: var(--surface); transition: .15s;
}
.profile-card.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-50); }
.pc-head { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.pc-ic { width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-soft); }
.pc-ic svg { width: 20px; height: 20px; }
.profile-card.active .pc-ic { background: var(--primary-100); color: var(--primary); }
.pc-name { font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-meta { font-size: 12.5px; color: var(--text-muted); line-height: 1.75; }
.pc-meta b { color: var(--text-soft); font-weight: 600; word-break: break-all; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.pc-actions form { display: inline-flex; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
    .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    .app.nav-open .sidebar-backdrop { display: block; }
    .main { margin-left: 0; }
    .icon-btn { display: inline-flex; }
    .topbar { padding: 14px 18px; }
    .content { padding: 22px 18px 50px; }
    .grid-2 { grid-template-columns: 1fr; }
}
