:root {
    --primary-color: #007aff;
    --sidebar-bg: #1c1c1e;
    --content-bg: #f5f5f7;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #8e8e93;
    --border-color: #d1d1d6;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--content-bg);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand {
    padding: 24px;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-links {
    list-style: none;
    margin-top: 20px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    color: #aeaeae;
    text-decoration: none;
    transition: all 0.2s;
}

.nav-link:hover {
    background: #2c2c2e;
    color: white;
}

.nav-link.active {
    background: #2c2c2e;
    color: white;
    border-left: 4px solid var(--primary-color);
}

.nav-icon {
    width: 24px;
    margin-right: 12px;
}

/* Main Content */
.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 30px;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
}

/* Cards & Grid */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.status-card {
    border-left: 5px solid var(--primary-color);
}

.status-card h3 {
    font-size: 14px;
    color: var(--text-muted);
}

.status-card .value {
    font-size: 28px;
    font-weight: bold;
    margin-top: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.input-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.input-field:focus {
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
    font-size: 14px;
}

.btn:active {
    opacity: 0.7;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-secondary {
    background: #e5e5ea;
    color: #333;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

/* Badges */
.badge {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}

.badge-primary {
    background: #e1f5fe;
    color: #0288d1;
}

.badge-secondary {
    background: #f5f5f5;
    color: #616161;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f8f9fa;
    text-align: left;
    padding: 15px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 15px;
    border-bottom: 1px solid #f2f2f7;
    font-size: 14px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    /* Slightly darker overlay */
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    /* Modern blur effect */
}

.modal-content {
    background: white;
    border-radius: 16px;
    /* Softer corners */
    width: 95%;
    /* Wider on small screens */
    max-width: 750px;
    /* Wider default */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    /* Prevent overflow */
    animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
    /* Subtle header bg */
    border-radius: 16px 16px 0 0;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #111;
}

.close-modal {
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    /* Scrollable content */
}

/* Barcode preview styles */
.clickable-barcode {
    cursor: pointer;
    display: inline-block;
    padding: 4px 6px;
    font-weight: 600;
}

#barcode-preview-modal .modal-content {
    max-width: 900px;
}

/* Make barcode cells more readable */
.table-container code {
    font-size: 16px;
    letter-spacing: 2px;
    background: #fff;
    padding: 6px 8px;
    display: inline-block;
}

/* Enhanced Form Elements */
.input-field {
    width: 100%;
    padding: 12px 14px;
    /* Larger touch target */
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: #fff;
    color: #333;
}

.input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.input-field::placeholder {
    color: #bbb;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    /* Darker label */
    margin-bottom: 6px;
}

/* Input Group for Add Button */
.input-group {
    display: flex;
    gap: 8px;
}


@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Utilities */
.flex-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.flex-1 {
    flex: 1;
}

.w-full {
    width: 100%;
    margin-top: 20px;
}

.mt-4 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

.text-right {
    text-align: right;
}

.clickable {
    cursor: pointer;
    color: var(--primary-color);
    text-decoration: underline;
}

.clickable:hover {
    opacity: 0.8;
}

.status-active {
    color: var(--success);
    font-weight: bold;
}

.status-used {
    color: var(--text-muted);
    text-decoration: line-through;
}

.status-void {
    color: var(--danger);
}

code {
    background: #f0f0f0;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

/* --- Category Management Tree --- */
.category-manager-layout {
    display: flex;
    gap: 20px;
    height: calc(100vh - 120px);
}

.category-tree-panel {
    flex: 1;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.category-edit-panel {
    width: 350px;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    height: fit-content;
}

.tree-list {
    list-style: none;
    padding-left: 0;
}

.tree-list ul {
    list-style: none;
    padding-left: 24px;
    border-left: 1px dashed var(--border-color);
    margin-left: 10px;
}

.tree-node {
    margin: 4px 0;
}

.tree-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.tree-content:hover {
    background: rgba(0, 122, 255, 0.05);
}

.tree-content.active {
    background: rgba(0, 122, 255, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 500;
}

.node-actions {
    display: none;
    gap: 8px;
}

.tree-content:hover .node-actions {
    display: flex;
}

/* --- Optimized Form Layouts --- */
.form-grid-layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    /* 12 column grid */
    gap: 16px;
    row-gap: 20px;
    padding: 0px 20px 10px 20px;
}

/* Utilities for grid spans */
.col-12 {
    grid-column: span 12;
}

.col-6 {
    grid-column: span 6;
}

.col-4 {
    grid-column: span 4;
}

.col-3 {
    grid-column: span 3;
}

.col-8 {
    grid-column: span 8;
}

.section-label {
    grid-column: span 12;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}