/* ============================================
   VARIABLES & RESET
   ============================================ */
:root {
    --primary: #041424;
    --secondary: #FCC404;
    --accent: #467FF7;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-primary: #041424;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --border-radius: 8px;
    --border-radius-sm: 6px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.025em;
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.section {
    background: var(--bg-primary);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #0a1f3a 100%);
    padding: 1rem;
}

.login-box {
    background: var(--bg-primary);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    border: 1px solid var(--border-color);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--primary);
    font-size: 1.75rem;
}

.login-box > p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.875rem;
}

.login-box .form-group {
    margin-bottom: 1.25rem;
}

.login-box label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.login-box input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.login-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(70, 127, 247, 0.1);
}

.login-box small {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.login-box small a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.login-box small a:hover {
    text-decoration: underline;
}

.btn-login {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 0.5rem;
}

.btn-login:hover {
    background-color: #3b6fe8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-login:active {
    transform: translateY(0);
}

/* ============================================
   APP HEADER
   ============================================ */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.app-header h1 {
    margin-bottom: 0;
    font-size: 1.75rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info span {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

/* ============================================
   BUTTONS
   ============================================ */
button {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

button:not(:disabled):active {
    transform: translateY(0);
}

.btn-logout {
    background-color: var(--danger);
    color: white;
    padding: 0.625rem 1rem;
}

.btn-logout:hover {
    background-color: #dc2626;
}

.btn-load {
    background-color: var(--accent);
    color: white;
}

.btn-load:hover {
    background-color: #3b6fe8;
}

.btn-save {
    background-color: var(--success);
    color: white;
}

.btn-save:hover {
    background-color: #059669;
}

.btn-generate {
    background-color: var(--primary);
    color: white;
    font-weight: 600;
}

.btn-generate:hover {
    background-color: #052d4a;
}

.btn-edit {
    background-color: var(--accent);
    color: white;
}

.btn-edit:hover {
    background-color: #3b6fe8;
}

.btn-save-fiscal {
    background-color: var(--success);
    color: white;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
}

.btn-save-fiscal:hover {
    background-color: #059669;
}

.btn-delete-fiscal {
    background-color: var(--danger);
    color: white;
}

.btn-delete-fiscal:hover {
    background-color: #dc2626;
}

.btn-cancel {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-cancel:hover {
    background-color: var(--border-color);
    box-shadow: none;
}

.btn-reset {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.375rem 0.625rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.btn-reset:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent);
    color: var(--accent);
    transform: rotate(180deg);
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
    width: 100%;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(70, 127, 247, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    appearance: none;
}

/* ============================================
   CHECKBOXES
   ============================================ */
input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
    accent-color: var(--accent);
}

input[type="checkbox"]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================
   STATUS MESSAGES
   ============================================ */
.status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    display: none;
    font-size: 0.875rem;
    font-weight: 500;
}

.status.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    display: block;
}

.status.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    display: block;
}

/* ============================================
   FISCAL PREVIEW & FORM
   ============================================ */
.fiscal-preview,
.config-preview {
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.fiscal-preview-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.fiscal-preview-section {
    background: var(--bg-primary);
    padding: 1.25rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.fiscal-preview-section h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: var(--primary);
    font-size: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
}

.fiscal-preview-section h4 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.fiscal-preview-section p {
    margin: 0.375rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

.fiscal-preview-section strong {
    color: var(--text-primary);
    font-weight: 600;
}

.fiscal-preview-actions,
.config-preview-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.fiscal-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.fiscal-section {
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.fiscal-section h3 {
    margin-bottom: 1rem;
    color: var(--primary);
    font-size: 1rem;
}

.fiscal-form-actions,
.config-form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* ============================================
   CONFIG PREVIEW & FORM
   ============================================ */
.config-preview-content {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.config-preview-item {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.config-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.config-value {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: 700;
}

.config-form {
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.rate-form {
    display: flex;
    align-items: flex-end;
    gap: 1.25rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.rate-form .form-group {
    margin-bottom: 0;
}

.rate-form input {
    width: 150px;
}

/* ============================================
   MONTH SELECTOR
   ============================================ */
.month-selector {
    display: flex;
    gap: 1.25rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.month-selector .form-group {
    margin-bottom: 0;
}

.month-selector select,
.month-selector input {
    min-width: 150px;
}

/* ============================================
   PREVIEW SUMMARY
   ============================================ */
.preview-summary {
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.summary-item {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.summary-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.summary-value.highlight {
    color: var(--accent);
    font-size: 1.5rem;
}

.progress-bar {
    height: 6px;
    background-color: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background-color: var(--success);
    transition: width 0.3s ease;
}

.progress-fill.warning {
    background-color: var(--warning);
}

.progress-fill.danger {
    background-color: var(--danger);
}

/* ============================================
   TABLE
   ============================================ */
.table-container {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.editable-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-primary);
}

.editable-table th {
    background-color: var(--primary);
    color: white;
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 10;
}

.editable-table th label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

.editable-table th input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.editable-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.editable-table tbody tr {
    transition: var(--transition);
}

.editable-table tbody tr:hover {
    background-color: var(--bg-secondary);
}

.editable-table tbody tr:last-child td {
    border-bottom: none;
}

.editable-input {
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.editable-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(70, 127, 247, 0.1);
}

.table-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* ============================================
   UTILITIES
   ============================================ */
.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .section {
        padding: 1rem;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .fiscal-preview-content {
        grid-template-columns: 1fr;
    }

    .table-container {
        overflow-x: scroll;
    }

    .editable-table {
        min-width: 800px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .app-header,
    .section:not(.section-print),
    .table-actions,
    button {
        display: none;
    }

    .section {
        box-shadow: none;
        border: none;
        page-break-inside: avoid;
    }
}
