* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;

    --sidebar: #0f172a;
    --sidebar-hover: #1e293b;

    --background: #f1f5f9;
    --surface: #ffffff;

    --text: #1e293b;
    --text-light: #64748b;

    --border: #e2e8f0;

    --success: #16a34a;
    --success-light: #f0fdf4;

    --warning: #d97706;
    --warning-light: #fffbeb;

    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --danger-light: #fef2f2;

    --muted: #64748b;
    --muted-dark: #475569;

    --shadow:
        0 4px 15px rgba(15, 23, 42, 0.06);

    --radius: 14px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family:
        Tahoma,
        Arial,
        sans-serif;

    background: var(--background);
    color: var(--text);

    min-height: 100vh;
    line-height: 1.7;
}


/* ==================================================
   SIDEBAR
================================================== */

.sidebar {
    position: fixed;

    right: 0;
    top: 0;

    width: 250px;
    height: 100vh;

    background: var(--sidebar);
    color: white;

    padding: 25px 16px;

    box-shadow:
        -5px 0 20px rgba(15, 23, 42, 0.12);

    z-index: 1000;
}

.logo {
    font-size: 24px;
    font-weight: bold;

    text-align: center;

    padding:
        12px 10px 30px;

    color: #ffffff;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar nav a {
    display: flex;
    align-items: center;

    min-height: 46px;

    padding:
        11px 15px;

    border-radius: 10px;

    text-decoration: none;

    color: #cbd5e1;

    font-size: 15px;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.sidebar nav a:hover {
    background: var(--sidebar-hover);
    color: #ffffff;

    transform: translateX(-2px);
}

.sidebar nav a.active {
    background: var(--primary);
    color: #ffffff;

    box-shadow:
        0 4px 12px rgba(37, 99, 235, 0.25);
}


/* ==================================================
   MAIN
================================================== */

.main {
    margin-right: 250px;

    padding: 30px;

    max-width: 1600px;
}


/* ==================================================
   TOPBAR
================================================== */

.topbar {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 20px;

    margin-bottom: 30px;
}

.topbar h1 {
    font-size: 28px;

    line-height: 1.4;

    margin-bottom: 6px;

    color: var(--text);
}

.topbar p {
    color: var(--text-light);

    font-size: 14px;
}

.user {
    background: var(--surface);

    border:
        1px solid var(--border);

    padding:
        10px 18px;

    border-radius: 10px;

    font-size: 14px;

    color: var(--text);

    box-shadow:
        0 2px 8px rgba(15, 23, 42, 0.04);
}


/* ==================================================
   DASHBOARD CARDS
================================================== */

.cards {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 20px;

    margin-bottom: 25px;
}

.card {
    position: relative;

    background: var(--surface);

    border:
        1px solid var(--border);

    border-radius: var(--radius);

    padding: 24px;

    box-shadow: var(--shadow);

    overflow: hidden;

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.card::before {
    content: "";

    position: absolute;

    right: 0;
    top: 0;

    width: 4px;
    height: 100%;

    background: var(--primary);
}

.card:hover {
    transform: translateY(-3px);

    box-shadow:
        0 8px 25px rgba(15, 23, 42, 0.09);
}

.card span {
    display: block;

    color: var(--text-light);

    font-size: 14px;

    margin-bottom: 10px;
}

.card strong {
    display: block;

    font-size: 21px;

    color: var(--text);
}


/* ==================================================
   SECTIONS
================================================== */

.welcome {
    background: var(--surface);

    border:
        1px solid var(--border);

    border-radius: var(--radius);

    padding: 25px;

    margin-bottom: 25px;

    box-shadow: var(--shadow);
}

.welcome h2 {
    font-size: 21px;

    margin-bottom: 10px;

    color: var(--text);
}

.welcome p {
    color: var(--text-light);

    line-height: 1.9;
}


/* ==================================================
   BUTTONS
================================================== */

button {
    border: none;

    border-radius: 9px;

    padding:
        10px 16px;

    background: var(--primary);

    color: white;

    font-family: inherit;

    font-size: 14px;

    cursor: pointer;

    transition:
        background 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease,
        opacity 0.2s ease;
}

button:hover {
    background: var(--primary-dark);

    transform: translateY(-1px);

    box-shadow:
        0 4px 10px rgba(37, 99, 235, 0.2);
}

button:active {
    transform: translateY(0);
    box-shadow: none;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}


/* ==================================================
   BUTTON VARIANTS
================================================== */

.btn-primary {
    background: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--muted);
}

.btn-secondary:hover {
    background: var(--muted-dark);
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn-success {
    background: var(--success);
}

.btn-success:hover {
    background: #15803d;
}

.btn-small {
    padding: 7px 11px;
    font-size: 13px;
}

.btn-cancel {
    background: #64748b;
}

.btn-cancel:hover {
    background: #475569;
}


/* ==================================================
   TABLE
================================================== */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-top: 20px;

    border-radius: 12px;
}

table {
    width: 100%;

    border-collapse: separate !important;

    border-spacing: 0;

    overflow: hidden;

    border:
        1px solid var(--border);

    border-radius: 12px;

    background: var(--surface);
}

thead {
    background: #f8fafc;
}

th {
    padding:
        15px 13px;

    text-align: right;

    font-size: 13px;

    font-weight: bold;

    color: #475569;

    border-bottom:
        1px solid var(--border);

    white-space: nowrap;
}

td {
    padding:
        14px 13px;

    text-align: right;

    border-bottom:
        1px solid #f1f5f9;

    font-size: 14px;

    color: #334155;

    white-space: nowrap;
}

tbody tr {
    transition:
        background 0.15s ease;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #f8fafc;
}

td button {
    padding:
        7px 11px;

    font-size: 13px;
}


/* ==================================================
   TABLE ACTIONS
================================================== */

.table-actions {
    display: flex;

    align-items: center;

    gap: 6px;

    flex-wrap: nowrap;
}

.table-actions button {
    margin: 0;
}


/* ==================================================
   FORMS
================================================== */

form {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 20px;

    margin-top: 20px;
}

.form-group {
    display: flex;

    flex-direction: column;

    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    grid-column: 1 / -1;

    display: flex;

    flex-direction: row;

    align-items: center;

    gap: 10px;

    margin-top: 5px;
}

label {
    font-size: 14px;

    font-weight: bold;

    color: #374151;
}

input,
select,
textarea {
    width: 100%;

    border:
        1px solid #cbd5e1;

    border-radius: 9px;

    padding:
        11px 13px;

    background: #ffffff;

    color: #111827;

    font-family: inherit;

    font-size: 14px;

    outline: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px
        rgba(37, 99, 235, 0.10);

    background: #ffffff;
}

textarea {
    min-height: 100px;

    resize: vertical;
}

select {
    cursor: pointer;
}


/* ==================================================
   FORM SECTION
================================================== */

.form-section {
    display: none;
}

.form-section.is-visible {
    display: block;
}


/* ==================================================
   PAGE ACTIONS
================================================== */

.page-actions {
    display: flex;

    align-items: center;

    gap: 10px;

    flex-wrap: wrap;

    margin-top: 20px;
}


/* ==================================================
   MESSAGES
================================================== */

.message {
    font-size: 14px;

    margin-top: 12px;

    min-height: 24px;
}

.message.success {
    color: var(--success);
}

.message.warning {
    color: var(--warning);
}

.message.error {
    color: var(--danger);
}

.message.info {
    color: var(--primary);
}


/* ==================================================
   SYNC STATUS
================================================== */

.sync-status {
    display: inline-flex;

    align-items: center;

    gap: 5px;

    padding:
        4px 9px;

    border-radius: 999px;

    font-size: 12px;

    white-space: nowrap;
}

.sync-status.synced {
    color: var(--success);

    background: var(--success-light);
}

.sync-status.pending {
    color: var(--warning);

    background: var(--warning-light);
}

.sync-status.error {
    color: var(--danger);

    background: var(--danger-light);
}


/* ==================================================
   CONTACTS
================================================== */

.contacts-header {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 15px;

    flex-wrap: wrap;
}

.contacts-header-text {
    min-width: 220px;
}

.contacts-header-actions {
    display: flex;

    align-items: center;

    gap: 10px;

    flex-wrap: wrap;
}


/* ==================================================
   EMPTY / LOADING TABLE
================================================== */

.table-message {
    text-align: center;

    color: var(--text-light);

    padding: 30px !important;
}


/* ==================================================
   RESPONSIVE
================================================== */

@media (max-width: 1100px) {

    .sidebar {
        width: 220px;
    }

    .main {
        margin-right: 220px;

        padding: 22px;
    }

    .cards {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}


/* ==================================================
   MOBILE
================================================== */

@media (max-width: 700px) {

    .sidebar {
        position: relative;

        width: 100%;

        height: auto;

        padding: 15px;
    }

    .logo {
        padding:
            8px 10px 15px;
    }

    .sidebar nav {
        display: grid;

        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 6px;
    }

    .sidebar nav a {
        justify-content: center;

        padding:
            10px 8px;

        font-size: 13px;
    }

    .main {
        margin-right: 0;

        padding: 15px;
    }

    .topbar {
        align-items: flex-start;

        flex-direction: column;

        margin-bottom: 20px;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .user {
        width: 100%;

        text-align: center;
    }

    .cards {
        grid-template-columns: 1fr;

        gap: 12px;
    }

    .card {
        padding: 20px;
    }

    .welcome {
        padding: 18px;
    }

    form {
        grid-template-columns: 1fr;

        gap: 16px;
    }

    .form-group.full-width {
        grid-column: auto;
    }

    .form-actions {
        grid-column: auto;
    }

    .contacts-header {
        align-items: flex-start;
    }

    .contacts-header-actions {
        width: 100%;
    }

    .contacts-header-actions button {
        flex: 1;
    }

    .table-wrapper {
        margin-top: 15px;
    }

    table {
        min-width: 900px;
    }

    td button {
        padding:
            7px 9px;

        font-size: 12px;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions button {
        flex: 1;
    }
}


/* ==================================================
   SMALL MOBILE
================================================== */

@media (max-width: 420px) {

    .sidebar nav {
        grid-template-columns: 1fr;
    }

    .sidebar nav a {
        justify-content: flex-start;

        padding:
            10px 14px;
    }

    .main {
        padding: 12px;
    }

    .welcome {
        padding: 15px;
    }

    .topbar h1 {
        font-size: 22px;
    }

    .card strong {
        font-size: 19px;
    }

    .contacts-header-actions {
        flex-direction: column;
    }

    .contacts-header-actions button {
        width: 100%;
    }

    .form-actions {
        flex-direction: column;

        align-items: stretch;
    }

    .form-actions button {
        width: 100%;
    }
}