/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-body: #0a0a0f;
    --bg-card: rgba(255,255,255,0.04);
    --bg-card-hover: rgba(255,255,255,0.07);
    --bg-input: rgba(255,255,255,0.06);
    --bg-header: #12121a;
    --border: rgba(255,255,255,0.1);
    --border-focus: #c9a84c;
    --text-primary: #f5f5f7;
    --text-secondary: #8a8a9a;
    --text-muted: #5a5a6a;
    --accent: #c9a84c;
    --accent-hover: #e4c76b;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --success: #27ae60;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
}
.screen.active {
    display: flex;
}

/* Login Screen */
#loginScreen {
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.login-logo {
    margin-bottom: 20px;
}
.login-logo img {
    max-height: 48px;
    width: auto;
}

.login-card h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--border-focus);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-error {
    font-size: 13px;
    color: var(--danger);
    margin-bottom: 12px;
    text-align: left;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #0a0a0f;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-outline:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-danger:hover:not(:disabled) {
    background: var(--danger);
    color: #fff;
}

.btn-full {
    width: 100%;
    padding: 12px;
    font-size: 15px;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* Dashboard Layout */
#dashboardScreen {
    flex-direction: column;
}

.dash-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.dash-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
}

.dash-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dash-logo img {
    border-radius: 4px;
}

.dash-title {
    font-size: 18px;
    font-weight: 600;
}

.dash-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dash-user {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Stats Bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 1200px;
    margin: 20px auto 0;
    padding: 0 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Navigation */
.dash-nav {
    display: flex;
    gap: 2px;
    max-width: 1200px;
    margin: 20px auto 0;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 12px 24px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Tab Content */
.tab-content {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 24px;
    width: 100%;
}

.tab-content.active {
    display: block;
}

/* Toolbar */
.tab-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-left {
    font-size: 14px;
    color: var(--text-secondary);
}

.toolbar-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Table */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    background: var(--bg-card);
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    word-break: break-word;
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.col-check {
    width: 40px;
    text-align: center;
}
.col-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}
.col-time { white-space: nowrap; min-width: 140px; }
.col-name { min-width: 120px; }
.col-phone { white-space: nowrap; min-width: 130px; }
.col-email { min-width: 150px; }
.col-desc { min-width: 180px; }
.col-city { min-width: 120px; }
.col-url {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.col-desc-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 16px;
}

/* Admin Cards */
#adminsList {
    display: grid;
    gap: 12px;
}

.admin-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.admin-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-info .admin-id {
    font-weight: 600;
    font-size: 15px;
}

.admin-info .admin-username {
    font-size: 13px;
    color: var(--text-secondary);
}

.admin-info .admin-flags {
    font-size: 12px;
    color: var(--text-muted);
}

.admin-remove-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-family: var(--font);
    color: var(--danger);
    background: transparent;
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}
.admin-remove-btn:hover {
    background: var(--danger);
    color: #fff;
}

/* Add Admin Form */
.add-admin-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.add-admin-form h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.add-admin-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.add-admin-row .form-input {
    flex: 1;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    z-index: 9999;
    animation: toastIn 0.3s ease;
    max-width: 400px;
}

.toast-success {
    background: var(--success);
    color: #fff;
}

.toast-error {
    background: var(--danger);
    color: #fff;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── User Dropdown ─── */
.user-dropdown {
    position: relative;
    cursor: pointer;
    user-select: none;
}

.user-dropdown .dash-user {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s;
}

.user-dropdown .dash-user:hover {
    border-color: var(--accent);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    min-width: 200px;
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 200;
    overflow: hidden;
}

.dropdown-menu.open {
    display: block;
}

.dropdown-item {
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.15s;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--bg-card-hover);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ─── Stats Detail Tab ─── */
.stats-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card-large {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
}

.stat-large-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
}

.stat-large-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* ─── Sticky Note Widget ─── */
.sticky-note-widget {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 300px;
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 500;
    overflow: hidden;
    transition: height 0.2s;
}

.sticky-note-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
    cursor: move;
}

.sticky-note-title {
    font-size: 13px;
    font-weight: 600;
}

.sticky-note-actions {
    display: flex;
    gap: 4px;
}

.sticky-note-expand-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
}

.sticky-note-expand-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.sticky-note-body {
    padding: 10px 14px;
}

.sticky-note-textarea {
    width: 100%;
    min-height: 80px;
    max-height: 300px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    resize: vertical;
    transition: border-color 0.2s;
}

.sticky-note-textarea:focus {
    border-color: var(--border-focus);
}

.sticky-note-textarea::placeholder {
    color: var(--text-muted);
}

.sticky-note-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    gap: 8px;
}

.sticky-note-meta {
    font-size: 11px;
    color: var(--text-muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sticky-note-footer .btn-xs {
    padding: 4px 10px;
    font-size: 11px;
}

/* ─── History Modal ─── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.6);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

/* ─── Web credentials in admin card ─── */
.admin-web-creds {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
    flex-wrap: wrap;
}

.admin-web-creds .web-creds-field {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 2px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font);
}

.web-creds-btn {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}

/* ─── Responsive ─── */
@media (max-width: 740px) {
    .admin-services-grid {
        grid-template-columns: 1fr;
    }
    .sticky-note-widget {
        width: 260px;
        right: 12px;
        bottom: 60px;
    }
    .modal-content {
        width: 95%;
    }
}

@media (max-width: 480px) {
    .stats-bar {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 24px;
    }
}

    .dash-header-inner {
        padding: 12px 16px;
    }

    .tab-content {
        padding: 16px;
    }

    .tab-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-right {
        justify-content: stretch;
    }

    .toolbar-right .btn {
        flex: 1;
    }

    .add-admin-row {
        flex-direction: column;
    }

    .login-card {
        margin: 20px;
    }
}

.flag-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-right: 12px;
}
.flag-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ─── Services Admin Grid ─── */
.admin-services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.admin-service-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s;
}

.admin-service-card:hover {
    border-color: rgba(255,255,255,0.2);
}

.admin-service-card.inactive {
    opacity: 0.55;
}

.admin-service-card.editing {
    border-color: var(--accent);
}

/* Card Header */
.asc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
}

.asc-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.asc-header-actions {
    display: flex;
    gap: 6px;
}

.asc-header-actions .btn-xs {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    line-height: 1;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--text-muted);
    border-radius: 10px;
    transition: background 0.2s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--success);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

.toggle-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Card Body */
.asc-body {
    padding: 16px 14px;
}

.asc-emoji {
    font-size: 36px;
    margin-bottom: 10px;
    line-height: 1;
}

.asc-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.3;
}

.asc-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.asc-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
}

/* Card Footer */
.asc-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 8px 14px;
    border-top: 1px solid var(--border);
}

.asc-footer .btn-xs {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
    line-height: 1;
}

/* Edit mode */
.admin-service-card.editing .asc-emoji-input {
    font-size: 28px;
    width: 60px;
    text-align: center;
    padding: 6px;
    margin-bottom: 10px;
}

.admin-service-card.editing .asc-edit-field {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 8px;
    font-size: 14px;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s;
}

.admin-service-card.editing .asc-edit-field:focus {
    border-color: var(--border-focus);
}

.admin-service-card.editing .asc-edit-field.emoji-input {
    font-size: 24px;
    width: 64px;
    text-align: center;
}

.admin-service-card.editing textarea.asc-edit-field {
    min-height: 60px;
    resize: vertical;
}

.admin-service-card.editing .asc-edit-price-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.admin-service-card.editing .asc-edit-price-row select {
    max-width: 80px;
    flex: none;
}

.admin-service-card.editing .asc-edit-price-row .asc-edit-field {
    flex: 1;
    max-width: 180px;
    margin-bottom: 0;
}

/* Inline add form (hidden toggle) */
#addServiceForm {
    display: none;
}

#addServiceForm.visible {
    display: block;
}

/* Responsive */
@media (max-width: 740px) {
    .admin-services-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-bar {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 24px;
    }
}
