* {
    box-sizing: border-box;
}

:root {
    --primary: #20b486;
    --primary-dark: #15966e;
    --bg: #f4f7f6;
    --white: #ffffff;
    --text: #17352d;
    --muted: #71817b;
    --border: #dce7e3;
    --danger: #dc4c4c;
    --sidebar: #12382e;
    --shadow: 0 10px 35px rgba(20, 60, 45, .08);
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}


/* =====================================================
   LOGIN
===================================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #edf8f3;
}

.login-wrapper {
    width: 100%;
    max-width: 430px;
}

.login-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.login-logo {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border-radius: 18px;
    background: var(--primary);
    color: #fff;
    font-size: 30px;
}

.login-card h1 {
    margin: 0;
    text-align: center;
    font-size: 25px;
}

.login-subtitle {
    margin: 8px 0 25px;
    color: var(--muted);
    text-align: center;
}

.login-card label {
    display: block;
    margin: 16px 0 7px;
    font-weight: 700;
}

.login-card input {
    width: 100%;
    height: 48px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
}

.login-card input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(32, 180, 134, .12);
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 65px;
}

.password-field button {
    position: absolute;
    right: 6px;
    top: 6px;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: #edf7f3;
    color: var(--primary-dark);
    cursor: pointer;
}

.btn {
    min-height: 46px;
    border: 0;
    border-radius: 10px;
    padding: 0 18px;
    cursor: pointer;
    font-weight: 700;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-full {
    width: 100%;
    margin-top: 24px;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 14px;
}

.alert-danger {
    background: #fff0f0;
    border: 1px solid #ffd1d1;
    color: #a52c2c;
}


/* =====================================================
   APP LAYOUT
===================================================== */

.app {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    width: 250px;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    color: #fff;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon {
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--primary);
    font-size: 21px;
}

.sidebar-brand strong,
.sidebar-brand span {
    display: block;
}

.sidebar-brand strong {
    font-size: 15px;
}

.sidebar-brand span {
    margin-top: 3px;
    color: #a7c7bd;
    font-size: 11px;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 12px;
}

.menu-label {
    padding: 12px 10px 8px;
    color: #7ea49a;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 45px;
    padding: 0 12px;
    margin-bottom: 4px;
    border-radius: 10px;
    color: #d6e7e2;
    font-size: 14px;
}

.menu-link:hover {
    background: rgba(255,255,255,.07);
}

.menu-link.active {
    background: var(--primary);
    color: #fff;
}

.menu-icon {
    width: 23px;
    text-align: center;
}

.sidebar-bottom {
    padding: 14px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #28574a;
    font-weight: 700;
}

.sidebar-user-info strong,
.sidebar-user-info span {
    display: block;
}

.sidebar-user-info strong {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.sidebar-user-info span {
    margin-top: 3px;
    color: #94b6ac;
    font-size: 11px;
}

.main {
    width: calc(100% - 250px);
    margin-left: 250px;
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 66px;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 0 28px;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    flex: 1;
    font-size: 15px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    color: var(--muted);
    font-size: 13px;
}

.logout-link {
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 700;
}

.mobile-menu-btn {
    display: none;
    border: 0;
    background: none;
    font-size: 24px;
    cursor: pointer;
}

.content {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px;
}


/* =====================================================
   DASHBOARD
===================================================== */

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 25px;
}

.page-heading h1 {
    margin: 0;
    font-size: 28px;
}

.page-heading p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 15px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 13px;
    background: #eaf8f3;
    font-size: 22px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.stat-card strong {
    display: block;
    margin-top: 5px;
    font-size: 20px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}

.panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 15px;
    box-shadow: var(--shadow);
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    margin: 0;
    font-size: 17px;
}

.panel-header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 17px 20px;
    border-bottom: 1px solid var(--border);
}

.quick-action:last-child {
    border-bottom: 0;
}

.quick-action:hover {
    background: #f8fbfa;
}

.quick-icon {
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 11px;
    background: #edf8f4;
    font-size: 20px;
}

.quick-action strong,
.quick-action small {
    display: block;
}

.quick-action strong {
    font-size: 14px;
}

.quick-action small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.welcome-panel {
    padding: 28px;
    text-align: center;
}

.welcome-icon {
    font-size: 45px;
}

.welcome-panel h2 {
    margin: 15px 0 8px;
    font-size: 19px;
}

.welcome-panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}


/* =====================================================
   MODULE PLACEHOLDER
===================================================== */

.empty-state {
    padding: 70px 25px;
    text-align: center;
}

.empty-icon {
    font-size: 50px;
    margin-bottom: 10px;
}

.empty-state h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.empty-state p {
    max-width: 520px;
    margin: 0 auto;
    color: var(--muted);
    line-height: 1.6;
}


/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 900px) {

    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 8px 0 30px rgba(0,0,0,.15);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main {
        width: 100%;
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: block;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-user .user-name {
        display: none;
    }

    .content {
        padding: 20px 15px 90px;
    }

    .page-heading {
        margin-bottom: 18px;
    }

    .page-heading h1 {
        font-size: 23px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .welcome-panel {
        padding: 25px 18px;
    }
}


@media (max-width: 480px) {

    .login-page {
        padding: 14px;
    }

    .login-card {
        padding: 25px 20px;
        border-radius: 17px;
    }

    .login-card h1 {
        font-size: 22px;
    }

    .content {
        padding-left: 12px;
        padding-right: 12px;
    }

    .topbar {
        height: 58px;
    }

    .topbar-title {
        font-size: 14px;
    }

    .logout-link {
        font-size: 12px;
    }

    .page-heading h1 {
        font-size: 21px;
    }

    .stat-card strong {
        font-size: 18px;
    }

}

/* =====================================================
   DANH MỤC HÀNG
===================================================== */

.module-grid {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 20px;
}

.form-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 17px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 700;
}

.form-group input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
    background: #fff;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(32, 180, 134, .1);
}

.form-help {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 22px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #edf2f0;
    color: var(--text);
}

.btn-secondary:hover {
    background: #e0e9e5;
}

.alert-success {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid #bdebd9;
    border-radius: 10px;
    background: #ecfaf5;
    color: #137252;
}

.panel-header-list {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 7px;
}

.search-form input {
    width: 210px;
    height: 40px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
}

.search-form input:focus {
    border-color: var(--primary);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 13px 15px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.data-table th {
    background: #f8faf9;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.data-table tbody tr:hover {
    background: #fafdfc;
}

.text-right {
    text-align: right !important;
}

.text-center {
    text-align: center !important;
}

.money {
    font-weight: 700;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.delete-form {
    display: inline;
}

.btn-small {
    min-height: 34px;
    padding: 0 10px;
    border-radius: 7px;
    font-size: 12px;
}

.btn-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #edf5ff;
    color: #2767a7;
}

.btn-edit:hover {
    background: #dcecff;
}

.btn-danger {
    background: #fff0f0;
    color: var(--danger);
}

.btn-danger:hover {
    background: #ffe0e0;
}


@media (max-width: 1100px) {

    .module-grid {
        grid-template-columns: 1fr;
    }

}


@media (max-width: 700px) {

    .panel-header-list {
        align-items: stretch;
        flex-direction: column;
    }

    .search-form {
        width: 100%;
    }

    .search-form input {
        flex: 1;
        width: auto;
    }

    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        padding: 12px 14px;
        border-bottom: 1px solid var(--border);
    }

    .data-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 15px;
        padding: 7px 0;
        border: 0;
        white-space: normal;
        text-align: right;
    }

    .data-table td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
        text-align: left;
    }

    .data-table td.text-center {
        text-align: right !important;
    }

    .table-actions {
        justify-content: flex-end;
    }

}