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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0d1117;
    color: #e1e4e8;
    line-height: 1.6;
}

nav {
    background: #161b22;
    border-bottom: 1px solid #21262d;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #58a6ff;
    margin-right: 2rem;
}

.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
    color: #8b949e;
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.15s;
}
.nav-links a:hover { color: #e1e4e8; background: #21262d; }

main {
    max-width: 1300px;
    margin: 2rem auto;
    padding: 0 2rem;
}

h2 {
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
    color: #f0f6fc;
}

/* Login */
.login-container {
    max-width: 380px;
    margin: 8rem auto;
    padding: 2rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
}
.login-container h1 { text-align: center; margin-bottom: 1.5rem; color: #58a6ff; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; color: #8b949e; }

input[type="text"], input[type="number"], input[type="url"], input[type="password"], select, textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e1e4e8;
    font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #58a6ff; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

.checkbox-group { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.checkbox-group label, .checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; color: #e1e4e8; font-size: 0.95rem; }

fieldset { border: 1px solid #30363d; border-radius: 8px; padding: 1.2rem; margin-bottom: 1.5rem; }
legend { color: #58a6ff; padding: 0 0.5rem; font-size: 0.95rem; font-weight: 600; }

/* Buttons */
.btn { display: inline-block; padding: 0.5rem 1rem; background: #21262d; border: 1px solid #30363d; border-radius: 6px; color: #e1e4e8; text-decoration: none; font-size: 0.9rem; cursor: pointer; transition: all 0.15s; }
.btn:hover { background: #30363d; }
.btn-primary { background: #238636; border-color: #2ea043; color: #fff; }
.btn-primary:hover { background: #2ea043; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.form-actions { margin-top: 1.5rem; display: flex; gap: 0.8rem; }
.actions { margin-bottom: 1.5rem; display: flex; gap: 0.8rem; }

/* Messages */
.error { background: #da363322; border: 1px solid #da3633; border-radius: 6px; padding: 0.8rem 1rem; margin-bottom: 1rem; color: #f85149; }
.success { background: #23863622; border: 1px solid #238636; border-radius: 6px; padding: 0.8rem 1rem; margin-bottom: 1rem; color: #3fb950; }
.hint { color: #8b949e; font-size: 0.9rem; margin-bottom: 1.5rem; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header h2 { margin-bottom: 0; }
.page-header__actions { display: flex; gap: 0.6rem; align-items: center; }

.filter-select {
    padding: 0.4rem 0.7rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e1e4e8;
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 160px;
}
.filter-select:focus { outline: none; border-color: #58a6ff; }

/* ============ DATA TABLE ============ */
.table-wrap {
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 12px;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead th {
    text-align: left;
    padding: 0.8rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #21262d;
    background: #0d1117;
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid #21262d;
    transition: background 0.1s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #1c2128; }

.data-table td {
    padding: 0.7rem 1rem;
    vertical-align: middle;
}

/* Column widths */
.col-status { width: 12px; padding: 0.7rem 0 0.7rem 1rem !important; }
.col-user { min-width: 160px; }
.col-traffic { min-width: 170px; }
.col-note { min-width: 120px; }
.col-manager { min-width: 130px; }
.col-actions { min-width: 220px; }

/* Status dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #484f58;
}
.status-dot.online { background: #3fb950; box-shadow: 0 0 6px #3fb95088; }
.status-dot.dot-active { background: #3fb950; }
.status-dot.dot-disabled { background: #f85149; }
.status-dot.dot-on_hold { background: #d29922; }
.status-dot.dot-limited { background: #f85149; }
.status-dot.dot-expired { background: #8b949e; }

/* Row states */
.row-disabled td { color: #f85149; }
.row-disabled .user-cell__name { color: #f85149; }
.row-disabled .user-cell__avatar { background: linear-gradient(135deg, #da3633, #f85149); }

.row-online .user-cell__name { color: #f0f6fc; }

/* User cell */
.user-cell { display: flex; align-items: center; gap: 0.7rem; }
.user-cell__avatar {
    width: 34px; height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, #1f6feb, #58a6ff);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.user-cell__info { display: flex; flex-direction: column; }
.user-cell__name { font-weight: 600; color: #f0f6fc; font-size: 0.9rem; line-height: 1.3; }

.status-label {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
    line-height: 1.4;
}
.status-label--online { background: #23863622; color: #3fb950; }
.status-label--offline { background: transparent; color: #6e7681; }

/* Traffic mini */
.traffic-mini { display: flex; align-items: center; gap: 0.6rem; }
.traffic-mini__bar { flex: 1; height: 4px; background: #21262d; border-radius: 2px; overflow: hidden; min-width: 60px; }
.traffic-mini__fill { height: 100%; border-radius: 2px; background: #238636; transition: width 0.3s; }
.traffic-mini__fill.warn { background: #d29922; }
.traffic-mini__fill.danger { background: #da3633; }
.traffic-mini__text { font-size: 0.75rem; color: #6e7681; font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace; white-space: nowrap; }

/* Note */
.note-inline { width: 100%; }
.note-display { display: flex; align-items: center; gap: 0.3rem; cursor: pointer; padding: 0.15rem 0.4rem; border-radius: 4px; transition: background 0.1s; min-height: 26px; }
.note-display:hover { background: #21262d; }
.note-display:hover .note-edit-icon { opacity: 1; }
.note-text { font-size: 0.85rem; color: #e1e4e8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.note-edit-icon { font-size: 0.7rem; opacity: 0; transition: opacity 0.1s; color: #484f58; }
.note-form { display: flex; gap: 0.25rem; align-items: center; }
.note-form .note-input { width: 140px; padding: 0.2rem 0.4rem; font-size: 0.85rem; background: #0d1117; border: 1px solid #30363d; border-radius: 4px; color: #e1e4e8; }
.note-form .note-input:focus { outline: none; border-color: #58a6ff; }
.note-btn { border: none; cursor: pointer; font-size: 0.85rem; padding: 0.15rem 0.3rem; border-radius: 4px; line-height: 1; background: transparent; }
.note-save { color: #3fb950; } .note-save:hover { background: #23863633; }
.note-cancel { color: #f85149; } .note-cancel:hover { background: #da363333; }

/* Sub link */
.sub-link-row { display: flex; gap: 0.3rem; align-items: center; }
.sub-link-input { flex: 1; padding: 0.25rem 0.5rem; background: #0d1117; border: 1px solid #21262d; border-radius: 4px; color: #6e7681; font-family: 'SF Mono', Monaco, monospace; font-size: 0.7rem; pointer-events: none; user-select: none; }
.btn-icon { flex-shrink: 0; font-size: 0.9rem; line-height: 1; padding: 0.25rem 0.45rem; }

/* Assign */
.assign-row { display: flex; align-items: center; }
.assign-row select { width: 100%; padding: 0.25rem 0.4rem; background: #0d1117; border: 1px solid #21262d; border-radius: 4px; color: #8b949e; font-size: 0.8rem; cursor: pointer; }
.assign-row select:focus { outline: none; border-color: #58a6ff; }

/* QR Modal */
.qr-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.qr-overlay--visible { display: flex; }
.qr-modal { background: #161b22; border: 1px solid #30363d; border-radius: 12px; padding: 1.5rem; min-width: 280px; }
.qr-modal__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; }
.qr-modal__title { font-weight: 600; color: #f0f6fc; }
.qr-modal__close { background: none; border: none; color: #8b949e; font-size: 1.4rem; cursor: pointer; line-height: 1; padding: 0 0.2rem; }
.qr-modal__close:hover { color: #f0f6fc; }
.qr-modal__body { display: flex; justify-content: center; }

/* Sub link page */
.sub-link-container { max-width: 700px; }
.success-box { background: #23863622; border: 1px solid #238636; border-radius: 8px; padding: 1.2rem; margin-bottom: 1.5rem; }
.success-box h3 { color: #3fb950; margin-bottom: 0.3rem; }
.success-box p { color: #8b949e; font-size: 0.9rem; }
.link-box { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 1.2rem; margin-bottom: 1.5rem; }
.link-box label { display: block; margin-bottom: 0.5rem; color: #58a6ff; font-size: 0.9rem; font-weight: 600; }
.copy-row { display: flex; gap: 0.5rem; }
.copy-row input { flex: 1; font-family: 'SF Mono', Monaco, monospace; font-size: 0.85rem; }
.info-box { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 1.2rem; margin-bottom: 1.5rem; }
.info-box h4 { color: #58a6ff; margin-bottom: 0.8rem; }
.info-table td { padding: 0.3rem 0.8rem 0.3rem 0; border: none; }
.info-table td:first-child { color: #8b949e; }

.empty { text-align: center; color: #484f58; padding: 3rem 2rem; font-size: 0.95rem; }

/* ============ MANAGERS ============ */
.manager-add-form { background: #161b22; border: 1px solid #21262d; border-radius: 12px; padding: 1.2rem; margin-bottom: 1.5rem; }
.form-inline { display: flex; gap: 0.5rem; align-items: center; }
.form-inline input { flex: 1; padding: 0.55rem 0.75rem; font-size: 0.9rem; }

.manager-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 1rem; }

.manager-card { background: #161b22; border: 1px solid #21262d; border-radius: 12px; padding: 1.2rem; transition: all 0.2s; }
.manager-card:hover { border-color: #30363d; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.manager-card__top { display: flex; justify-content: space-between; align-items: center; }
.manager-card__info { display: flex; align-items: center; gap: 0.8rem; }
.manager-card__icon { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #8957e5, #bc8cff); display: flex; align-items: center; justify-content: center; font-size: 1rem; color: #fff; flex-shrink: 0; }
.manager-card__details { display: flex; flex-direction: column; }
.manager-card__name { font-weight: 600; color: #f0f6fc; font-size: 0.95rem; }
.manager-card__count { font-size: 0.8rem; color: #8b949e; }
.manager-card__actions { display: flex; gap: 0.4rem; align-items: center; }

.btn-danger { background: #da363322; border-color: #da3633; color: #f85149; }
.btn-danger:hover { background: #da363344; }
.btn-outline { background: transparent; border-color: #30363d; color: #8b949e; }
.btn-outline:hover { background: #21262d; color: #e1e4e8; }

.inbounds-panel { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #21262d; }
.inbounds-panel__label { font-size: 0.8rem; color: #6e7681; margin-bottom: 0.6rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.inbounds-panel__list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.inbound-tag { cursor: pointer; border: 1px solid transparent; font-size: 0.8rem; font-family: 'SF Mono', Monaco, monospace; color: #c9d1d9; background: #21262d; padding: 0.2rem 0.6rem; border-radius: 6px; transition: all 0.15s; }
.inbounds-panel .checkbox-label input[type="checkbox"] { display: none; }
.inbounds-panel .checkbox-label:has(input:checked) .inbound-tag { background: #1f6feb33; border-color: #1f6feb55; color: #58a6ff; }
.inbounds-panel .checkbox-label:has(input:not(:checked)) .inbound-tag { opacity: 0.5; }

/* Create user modal */
.create-modal { background: #161b22; border: 1px solid #30363d; border-radius: 12px; padding: 1.5rem; min-width: 360px; }
.create-form { display: flex; flex-direction: column; gap: 0.8rem; }
.create-form__group { display: flex; flex-direction: column; gap: 0.3rem; }
.create-form__group label { font-size: 0.85rem; color: #8b949e; }
.create-form__group input { padding: 0.55rem 0.75rem; background: #0d1117; border: 1px solid #21262d; border-radius: 6px; color: #e1e4e8; font-size: 0.9rem; }
.create-form__group input:focus { outline: none; border-color: #58a6ff; }
.create-form__submit { margin-top: 0.5rem; padding: 0.6rem; font-size: 0.95rem; }

input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    nav { padding: 0 1rem; }
    .nav-brand { margin-right: 1rem; font-size: 1rem; }
    .nav-links a { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
    main { padding: 0 1rem; margin: 1.5rem auto; }
    .table-wrap { overflow-x: auto; }
    .data-table { min-width: 700px; }
    .manager-list { grid-template-columns: 1fr; }
    .form-inline { flex-wrap: wrap; }
}
