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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background: #1a1a2e;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 52px;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; }
.nav-links a {
    color: #a0a0c0;
    text-decoration: none;
    margin-left: 20px;
    font-size: 0.9rem;
    transition: color .2s;
}
.nav-links a:hover, .nav-links a.active { color: #fff; }

/* Container */
.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }

/* Auth box */
.auth-box {
    max-width: 400px;
    margin: 80px auto;
    background: #fff;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.auth-box h1 { margin-bottom: 20px; font-size: 1.4rem; }

/* Flash messages */
.flash {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.flash-error   { background: #fde8e8; color: #c0392b; }
.flash-success { background: #e8fde8; color: #27ae60; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: #555;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 0.9rem;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,.15);
}
.input-wide { max-width: 100%; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 150px; }

fieldset {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
}
legend { font-weight: 700; padding: 0 8px; font-size: 0.95rem; }

/* Buttons */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background .2s;
}
.btn-primary { background: #2980b9; color: #fff; }
.btn-primary:hover { background: #2471a3; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* Stats */
.stats-row { display: flex; gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: #fff;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    text-align: center;
    min-width: 120px;
}
.stat-value { font-size: 2rem; font-weight: 700; color: #2980b9; }
.poller-on { color: #27ae60; }
.poller-off { color: #e74c3c; }
.stat-label { font-size: 0.8rem; color: #888; margin-top: 2px; }

/* Filters */
.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    align-items: end;
    flex-wrap: wrap;
}
.filters input, .filters select {
    padding: 6px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Table */
.data-table {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    border-collapse: collapse;
    font-size: 0.88rem;
}
.data-table th {
    background: #f8f9fa;
    text-align: left;
    padding: 10px 14px;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #666;
    border-bottom: 2px solid #eee;
}
.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
}
.data-table tr:hover td { background: #fafbfc; }
.empty { text-align: center; color: #aaa; padding: 24px !important; }
.actions { white-space: nowrap; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-invoice, .badge-invoice_30d, .badge-invoice_14d, .badge-invoice_7d {
    background: #dbeafe; color: #1e40af;
}
.badge-receipt, .badge-fiscal_receipt {
    background: #fef3c7; color: #92400e;
}
.badge-ok    { background: #d1fae5; color: #065f46; }
.badge-off   { background: #f3f4f6; color: #6b7280; }
.badge-error { background: #fee2e2; color: #991b1b; }

/* Pagination */
.pagination {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    margin-top: 16px;
    font-size: 0.9rem;
}
.pagination a { color: #2980b9; text-decoration: none; }

/* Settings form */
.settings-form { background: #fff; padding: 24px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.rule-form { margin-top: 12px; }

h1 { margin-bottom: 16px; }
h2 { margin: 24px 0 12px; }
h3 { margin: 16px 0 8px; font-size: 1rem; }
hr { border: none; border-top: 1px solid #e0e0e0; margin: 24px 0; }
.help-text { font-size: 0.85rem; color: #888; margin-bottom: 12px; }

/* Input with button */
.input-with-btn { display: flex; gap: 6px; }
.input-with-btn input { flex: 1; }

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-box {
    background: #fff;
    border-radius: 10px;
    width: 460px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px 10px;
}
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-close {
    background: none; border: none; font-size: 1.5rem;
    cursor: pointer; color: #999; line-height: 1;
}
.modal-close:hover { color: #333; }
.modal-search {
    margin: 0 20px 10px;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 0.9rem;
}
.modal-search:focus { outline: none; border-color: #3498db; }
.modal-list {
    overflow-y: auto;
    padding: 0 10px 14px;
    flex: 1;
}
.status-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
}
.status-item:hover { background: #f0f4ff; }
.status-color {
    width: 14px; height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-name { flex: 1; font-size: 0.9rem; }
.status-id { font-size: 0.8rem; color: #999; }
.modal-loading, .modal-empty, .modal-error {
    text-align: center; padding: 24px; color: #888; font-size: 0.9rem;
}
.modal-error { color: #c0392b; }

/* Badge for INVOICE_0D */
.badge-invoice_0d { background: #d1fae5; color: #065f46; }
