/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.6;
    min-height: 100vh;
}
a { color: #4361ee; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === LAYOUT === */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand h2 { font-size: 1.3rem; letter-spacing: 1px; }
.sidebar-brand span { font-size: .75rem; color: #aaa; }
.sidebar-nav { display: flex; flex-direction: column; padding: 10px 0; }
.sidebar-nav a {
    color: #ccc;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: .2s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,.05);
    color: #fff;
    border-left-color: #4361ee;
}
.nav-icon { width: 20px; text-align: center; }

.main-content { flex: 1; display: flex; flex-direction: column; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 25px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}
.topbar h2 { font-size: 1.2rem; }
.topbar-right { display: flex; align-items: center; gap: 15px; }
.user-badge { color: #666; font-size: .85rem; }
.content { padding: 20px 25px; flex: 1; }

/* === CARDS === */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
}
.card-header h3 { font-size: .95rem; font-weight: 600; }
.card-body { padding: 20px; }

/* === STATS === */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 15px; margin-bottom: 20px; }
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    text-align: center;
}
.stat-card.warning { border-left: 4px solid #f8961e; }
.stat-card.danger  { border-left: 4px solid #e63946; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: #1a1a2e; }
.stat-label { font-size: .8rem; color: #888; margin-top: 4px; }

/* === TABLES === */
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f0f0f0; }
.table th { font-weight: 600; color: #666; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; }
.table tbody tr:hover { background: #f8f9fa; }
.table code { background: #f0f0f0; padding: 2px 6px; border-radius: 3px; font-size: .8rem; }

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-pending    { background: #fff3cd; color: #856404; }
.badge-paid       { background: #d4edda; color: #155724; }
.badge-dispensing { background: #cce5ff; color: #004085; }
.badge-dispensed  { background: #d4edda; color: #155724; }
.badge-timeout    { background: #f8d7da; color: #721c24; }
.badge-refunded   { background: #e2e3e5; color: #383d41; }
.badge-failed     { background: #f8d7da; color: #721c24; }
.badge-online     { background: #d4edda; color: #155724; }
.badge-offline    { background: #e2e3e5; color: #383d41; }
.badge-maintenance { background: #fff3cd; color: #856404; }
.badge-error      { background: #f8d7da; color: #721c24; }

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border: 1px solid #d0d0d0; border-radius: 6px;
    background: #fff; color: #333; font-size: .85rem; cursor: pointer;
    transition: .2s; white-space: nowrap;
}
.btn:hover { background: #f5f5f5; }
.btn-primary { background: #4361ee; color: #fff; border-color: #4361ee; }
.btn-primary:hover { background: #3651d4; }
.btn-sm { padding: 4px 10px; font-size: .78rem; }
.btn-block { width: 100%; }

/* === FORMS === */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: .82rem; font-weight: 600; color: #555; margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 8px 12px; border: 1px solid #d0d0d0; border-radius: 6px;
    font-size: .85rem; transition: .2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: #4361ee; box-shadow: 0 0 0 3px rgba(67,97,238,.15);
}

/* === ALERT === */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 15px; font-size: .85rem; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* === MACHINE GRID === */
.machine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; }
.machine-card {
    padding: 16px; border-radius: 8px; border: 1px solid #e0e0e0;
    transition: .2s; cursor: default;
}
.machine-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.machine-card.status-online      { border-left: 4px solid #2d6a4f; }
.machine-card.status-offline     { border-left: 4px solid #999; }
.machine-card.status-maintenance { border-left: 4px solid #e9c46a; }
.machine-card.status-error       { border-left: 4px solid #e63946; }
.machine-name { font-weight: 600; font-size: .95rem; }
.machine-id   { font-size: .75rem; color: #888; }
.machine-status { font-size: .8rem; margin-top: 6px; text-transform: capitalize; }
.machine-heartbeat { font-size: .72rem; color: #aaa; margin-top: 4px; }

/* === FILTER FORM === */
.filter-form { display: flex; gap: 15px; flex-wrap: wrap; align-items: flex-end; }

/* === LOGIN PAGE === */
.login-page {
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
.login-card {
    background: #fff; border-radius: 12px; padding: 40px; width: 100%; max-width: 380px;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.login-header { text-align: center; margin-bottom: 25px; }
.login-header h1 { color: #1a1a2e; font-size: 1.6rem; }
.login-header p { color: #888; font-size: .85rem; margin-top: 4px; }

/* === PAGINATION === */
.pagination { display: flex; gap: 6px; margin-top: 15px; justify-content: center; }
.page-link {
    padding: 6px 12px; border: 1px solid #d0d0d0; border-radius: 4px;
    font-size: .8rem; color: #333; transition: .2s;
}
.page-link:hover, .page-link.active { background: #4361ee; color: #fff; border-color: #4361ee; text-decoration: none; }

/* === MODAL === */
.modal {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 1000; align-items: center; justify-content: center;
}
.modal-content {
    background: #fff; border-radius: 10px; padding: 30px; width: 90%; max-width: 480px;
    max-height: 90vh; overflow-y: auto; position: relative;
}
.modal h3 { margin-bottom: 20px; }
.close {
    position: absolute; top: 12px; right: 16px; font-size: 1.5rem;
    cursor: pointer; color: #888;
}
.close:hover { color: #000; }

/* === BAR CHART === */
.bar-chart {
    display: flex; gap: 8px; align-items: flex-end; height: 200px;
    padding: 0 10px; border-bottom: 1px solid #e0e0e0;
}
.bar-chart.hourly { height: 140px; }
.bar-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    height: 100%; justify-content: flex-end;
}
.bar-fill {
    width: 100%; max-width: 40px; background: linear-gradient(to top, #4361ee, #48bfe3);
    border-radius: 4px 4px 0 0; transition: .3s; position: relative;
    min-height: 4px;
}
.bar-fill span {
    position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
    font-size: .7rem; color: #555; white-space: nowrap;
}
.bar-label { font-size: .65rem; color: #888; margin-top: 4px; text-align: center; }
.bar-sub { font-size: .6rem; color: #aaa; }

/* === GRID-2 === */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* === UNREAD ROW === */
tr.unread { font-weight: 600; background: #f0f4ff; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-brand h2, .sidebar-brand span, .sidebar-nav a span:not(.nav-icon) { display: none; }
    .sidebar-nav a { justify-content: center; padding: 12px; }
    .grid-2 { grid-template-columns: 1fr; }
    .content { padding: 15px; }
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f0f0f0; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }
