
:root {
    --primary-color: #1893e6;
    --secondary-color: #039e44;
    --danger-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
}

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f7fa;
    color: #333;
}

.container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: var(--dark-color);
    color: white;
    transition: all 0.3s;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.2);
    text-align: center;
}

.sidebar-menu {
    padding: 0;
    list-style: none;
}

.sidebar-menu li {
    position: relative;
}

.sidebar-menu li a {
    display: block;
    padding: 15px 20px;
    color: white;
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-menu li a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-menu li a i {
    margin-left: 10px;
}

.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.datetime {
    font-size: 14px;
    color: #555;
}

.card {
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.btn {
    display: inline-block;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-light {
    background-color: var(--light-color);
    color: #333;
}

.btn:hover {
    opacity: 0.9;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid #ddd;
}

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.table tr:hover {
    background-color: #f5f5f5;
}

.table-row-registered {
    background-color: rgba(46, 204, 113, 0.1);
}

.table-row-manual {
    background-color: rgba(52, 152, 219, 0.1);
}

.archived {
    background-color: #f8d7da;
    opacity: 0.7;
}

.collapse {
    display: none;
}

.collapse.show {
    display: block;
}

.toggle-btn {
    cursor: pointer;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f5f7fa;
}

.login-card {
    width: 400px;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.login-header {
    padding: 20px;
    background-color: var(--dark-color);
    color: white;
    text-align: center;
}

.login-body {
    padding: 30px;
}

.alert {
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.quantity-form {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.quantity-form input[type="number"] {
    width: 60px;
    padding: 5px;
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}
/* ===== Stage 5: responsive system-wide refinements ===== */
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
img, video, canvas, iframe { max-width: 100%; height: auto; }
.container { width: 100%; min-width: 0; }
.main-content { min-width: 0; width: calc(100% - 250px); }
.header { gap: 16px; }
.header h1, .header h2, .header h3 { margin: 0; line-height: 1.5; }
.header-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-user-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 14px; }
.header-user-meta .datetime { white-space: nowrap; }
.back-dashboard-btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; }
.mobile-menu-toggle { display: none; border: 0; background: var(--dark-color); color: #fff; width: 42px; height: 42px; border-radius: 8px; cursor: pointer; flex: 0 0 auto; }
.mobile-sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 998; }
.mobile-sidebar-overlay.is-visible { display: block; }
.table-responsive, .table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { min-width: max-content; }
.table th, .table td { vertical-align: middle; }
input, select, textarea, button { max-width: 100%; font: inherit; }
input[type="file"] { width: 100%; }
.actions, .form-actions { min-width: max-content; }
.card, .panel, .stat, .chart-box { min-width: 0; }
.dashboard-cards { align-items: stretch; }
.dashboard-cards .card { min-width: 0; }
.modal, .modal-content, .modal-dialog { max-width: calc(100vw - 24px); }

@media (max-width: 992px) {
  .container { display: block; }
  .sidebar { position: fixed; top: 0; right: -285px; width: 280px; max-width: 86vw; height: 100dvh; z-index: 999; box-shadow: -8px 0 25px rgba(0,0,0,.22); transition: right .25s ease; }
  .sidebar.is-open { right: 0; }
  .sidebar-header { position: sticky; top: 0; z-index: 2; }
  .sidebar-menu { padding-bottom: 30px; }
  .main-content { width: 100%; padding: 16px; overflow: visible; }
  .mobile-menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .header { align-items: flex-start; margin-bottom: 20px; padding-bottom: 12px; }
  .header-user-meta { align-items: flex-end; }
  .form-row { flex-wrap: wrap; }
  .form-row .form-group { flex: 1 1 260px; }
}

@media (max-width: 768px) {
  .main-content { padding: 12px; }
  .header { flex-direction: column; gap: 10px; }
  .header-title-row { width: 100%; }
  .header-title-row h2 { font-size: 1.18rem; overflow-wrap: anywhere; }
  .header-user-meta { width: 100%; align-items: flex-start; }
  .back-dashboard-btn { width: 100%; justify-content: center; }
  .card, .panel { border-radius: 10px; }
  .card-body, .panel { padding: 12px; }
  .dashboard-cards { display: grid !important; grid-template-columns: 1fr !important; gap: 12px !important; }
  .form-row, .grid, .search-row { grid-template-columns: 1fr !important; flex-direction: column; }
  .form-row .form-group, .form-group { width: 100%; min-width: 0 !important; }
  .btn { min-height: 42px; }
  .actions { min-width: 0; width: 100%; }
  .actions .btn, .actions form, .actions form .btn { flex: 1 1 auto; }
  .table th, .table td { padding: 9px 10px; font-size: 13px; }
  .login-container { min-height: 100dvh; height: auto; padding: 16px; }
  .login-card { width: 100%; max-width: 430px; }
  .login-body { padding: 20px 16px; }
}

@media (max-width: 480px) {
  .main-content { padding: 8px; }
  .header { padding: 10px 4px 12px; }
  .header-title-row h2 { font-size: 1.05rem; }
  .mobile-menu-toggle { width: 40px; height: 40px; }
  .btn { width: 100%; text-align: center; justify-content: center; }
  .actions { flex-direction: column; }
  .actions > *, .actions form { width: 100%; }
  .quantity-form { display: grid; grid-template-columns: 1fr auto; width: 100%; }
  .quantity-form input[type="number"] { width: 100%; }
}

/* Stage 5.1: dashboard return link lives in the sidebar menu */
.sidebar-menu .sidebar-back-link {
    font-weight: 700;
}
.sidebar-menu .sidebar-back-link i {
    margin-left: 8px;
}
