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

body {
    font-family: Calibri, Candara, 'Segoe UI', Tahoma, sans-serif;
    background-color: #f4f4f5;
    color: #1f2328;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* Menubar */
.menubar {
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
}

.menubar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.menubar-title {
    font-size: 1.15em;
    font-weight: 700;
    letter-spacing: .2px;
    white-space: nowrap;
}

.menubar-nav {
    display: flex;
    gap: 8px;
    flex: 1;
}

.menubar-nav a {
    padding: 8px 14px;
    border-radius: 4px;
    font-size: .95em;
    color: #4b5563;
}

.menubar-nav a:hover { background-color: #f4f4f5; color: #1f2328; }
.menubar-nav a.active { background-color: #1f2328; color: #fff; }

.menubar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: .9em;
    color: #4b5563;
    white-space: nowrap;
}

.menubar-user a { border: 1px solid #d0d0d0; padding: 6px 12px; border-radius: 4px; }
.menubar-user a:hover { background-color: #f4f4f5; }

/* Content */
.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

h1 { font-size: 1.4em; font-weight: 700; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.message {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: .95em;
    border: 1px solid transparent;
}

.message.success { background-color: #eef8f0; color: #1e6b34; border-color: #c9e9d0; }
.message.error { background-color: #fdeeee; color: #a11c1c; border-color: #f3caca; }

.muted { color: #6b7280; font-size: .9em; margin-bottom: 16px; }

.section-title { font-size: 1.1em; font-weight: 700; margin: 28px 0 10px; }

/* Thanh lọc gọn, phụ trợ cho bảng (VD: trang Nhật Ký) */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 20px;
}

.filter-bar .form-group {
    margin-bottom: 0;
    min-width: 160px;
}

.filter-bar label {
    font-size: .8em;
}

.filter-bar .button-group {
    margin-top: 0;
}

/* Form */
.form-section {
    background-color: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 24px;
    max-width: 640px;
}

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

label { display: block; margin-bottom: 6px; color: #4b5563; font-size: .9em; font-weight: 600; }

input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: .95em;
    font-family: inherit;
    color: #1f2328;
    background-color: #fff;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: #1f2328; }
textarea { resize: vertical; min-height: 80px; }

input[readonly], input:disabled {
    background-color: #f0f0f1;
    color: #6b7280;
    cursor: not-allowed;
}

.field-hint { display: block; margin-top: 4px; font-size: .78em; color: #a11c1c; min-height: 1.2em; }
input.input-valid { border-color: #1e6b34; }
input.input-invalid { border-color: #a11c1c; }

.button-group { display: flex; gap: 10px; margin-top: 20px; }

.btn {
    display: inline-block;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: .9em;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
}

.btn-primary { background-color: #1f2328; color: #fff; }
.btn-primary:hover { background-color: #000; }
.btn-secondary { background-color: #fff; color: #1f2328; border-color: #d0d0d0; }
.btn-secondary:hover { background-color: #f4f4f5; }
.btn-outline { background-color: #fff; color: #1f2328; border-color: #d0d0d0; }
.btn-outline:hover { background-color: #f4f4f5; }
.btn-danger-outline { background-color: #fff; color: #a11c1c; border-color: #eec9c9; }
.btn-danger-outline:hover { background-color: #fdeeee; }
.btn-block { width: 100%; }

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    overflow: hidden;
}

thead { background-color: #fafafa; }
th { padding: 12px 14px; text-align: left; font-weight: 700; font-size: .85em; color: #4b5563; border-bottom: 1px solid #e5e5e5; }
td { padding: 12px 14px; border-bottom: 1px solid #eee; font-size: .92em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background-color: #fafafa; }

.clickable-row { cursor: pointer; }

.expanding-section {
    display: none;
    margin-top: 20px;
}

.expanding-section.open { display: block; }

th a { color: inherit; }
th a:hover { text-decoration: underline; }

.status-active { color: #1e6b34; font-weight: 600; }
.status-inactive { color: #a11c1c; font-weight: 600; }

.action-buttons { display: flex; gap: 8px; }
.action-buttons form { display: inline; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
}
.btn-icon svg { display: block; width: 16px; height: 16px; }

.no-data { text-align: center; color: #9ca3af; padding: 32px; }

tbody tr.empty-row:hover { background-color: transparent; }

/* Phân trang */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background-color: #fff;
    font-size: .9em;
    color: #1f2328;
}

a.page-link:hover { background-color: #f4f4f5; }
.page-link.current { background-color: #1f2328; color: #fff; border-color: #1f2328; }
.page-link.disabled { color: #9ca3af; cursor: default; }
.page-ellipsis { padding: 0 4px; color: #6b7280; }

/* Modal (dùng cho form Thêm / Điều Chỉnh) */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(31, 35, 40, .45);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-overlay.open { display: flex; }

.modal-box {
    background: #fff;
    border-radius: 6px;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
}

.modal-box h2 { font-size: 1.2em; font-weight: 700; margin-bottom: 20px; }

/* Login page (không có menubar) */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f4f4f5;
    padding: 20px;
}

.login-box {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 36px;
    width: 100%;
    max-width: 360px;
}

.login-box h1 { text-align: center; margin-bottom: 24px; font-size: 1.3em; }
