/* Global module UI consistency baseline.
   Safe defaults for typography, spacing, controls, cards, table, and actions.
*/

:root {
    --ui-font-family: 'Google Sans', 'Segoe UI', Roboto, Arial, sans-serif;
    --ui-font-size: 13px;
    --ui-line-height: 1.45;
    --ui-text: #3c4043;
    --ui-text-soft: #5f6368;
    --ui-title: #202124;
    --ui-border: #dadce0;
    --ui-border-soft: #e7ebf1;
    --ui-surface: #ffffff;
    --ui-surface-soft: #f8f9fa;
    --ui-shadow-light: 0 1px 3px rgba(60, 64, 67, 0.1), 0 2px 6px rgba(60, 64, 67, 0.08);
    --ui-primary: #1a73e8;
    --ui-success: #137333;
    --ui-warning: #b06000;
    --ui-danger: #c5221f;
}

:where(.module-shell, .billing-shell, .ftth-shell, .mikrotik-shell, .paycash-shell, .config-shell) {
    font-family: var(--ui-font-family);
    font-size: var(--ui-font-size);
    line-height: var(--ui-line-height);
    color: var(--ui-text);
}

:where(.module-shell, .billing-shell, .ftth-shell, .mikrotik-shell, .paycash-shell, .config-shell)
:where(input, select, textarea, button, label, td, th, p, a, span) {
    font-family: inherit;
    font-size: 13px;
}

:where(.module-shell, .billing-shell, .ftth-shell, .mikrotik-shell, .paycash-shell, .config-shell) .material-icons {
    font-family: 'Material Icons' !important;
}

:where(.module-shell, .billing-shell, .ftth-shell, .mikrotik-shell, .paycash-shell, .config-shell) {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.billing-hero {
    background: linear-gradient(135deg, #e8f0fe 0%, #fff 58%, #f3f5f8 100%);
    border: 1px solid var(--ui-border-soft);
    border-radius: 20px;
    box-shadow: var(--ui-shadow-light);
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    padding: 18px 20px;
}

.billing-hero h2 {
    margin: 0 0 4px;
    color: var(--ui-title);
    font-size: 28px;
    font-weight: 700;
}

.billing-hero p {
    margin: 0;
    color: var(--ui-text-soft);
    font-size: 13px;
}

.hero-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.hero-actions a,
.hero-actions button {
    border: 1px solid var(--ui-border);
    border-radius: 999px;
    padding: 8px 13px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    color: var(--ui-text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.hero-actions a:hover,
.hero-actions button:hover {
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.12);
}

.hero-actions .material-icons {
    font-size: 16px;
    line-height: 1;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    margin: 0;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--ui-border-soft);
    border-radius: 14px;
    box-shadow: var(--ui-shadow-light);
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-card h4 {
    margin: 0 0 2px;
    font-size: 13px;
    color: var(--ui-text-soft);
}

.stat-card p {
    margin: 0;
    font-size: 20px;
    color: var(--ui-title);
    font-weight: 700;
}

.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.billing-card {
    background: var(--ui-surface);
    border: 1px solid var(--ui-border-soft);
    border-radius: 16px;
    box-shadow: var(--ui-shadow-light);
    padding: 12px;
}

.billing-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.billing-toolbar input,
.billing-toolbar select,
.billing-toolbar textarea,
.form-grid input,
.form-grid select,
.form-grid textarea {
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    background: #fff;
    min-width: 120px;
}

.billing-toolbar button,
.billing-toolbar a,
.btn-primary,
.btn-neutral,
.btn-success,
.btn-danger,
.gbtn {
    border: none;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.btn-primary,
.gbtn.primary {
    background: var(--ui-primary);
    color: #fff;
}

.btn-neutral,
.gbtn.neutral {
    background: #f1f3f4;
    color: var(--ui-text);
}

.btn-success,
.gbtn.success {
    background: #e6f4ea;
    color: var(--ui-success);
}

.btn-danger,
.gbtn.danger {
    background: #fce8e6;
    color: var(--ui-danger);
}

.gbtn.warn {
    background: #fef7e0;
    color: var(--ui-warning);
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--ui-border-soft);
    border-radius: 12px;
    background: #fff;
}

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

.billing-table th,
.billing-table td {
    padding: 8px 10px;
    font-size: 13px;
    border-bottom: 1px solid #edf0f2;
    vertical-align: middle;
}

.billing-table th {
    text-transform: uppercase;
    color: var(--ui-text-soft);
    background: var(--ui-surface-soft);
    position: sticky;
    top: 0;
    z-index: 1;
}

.billing-table tbody tr:hover {
    background: #f8fbff;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1;
}

.chip-ok { background: #e6f4ea; color: var(--ui-success); }
.chip-warn { background: #fef7e0; color: var(--ui-warning); }
.chip-bad { background: #fce8e6; color: var(--ui-danger); }
.chip-neutral { background: #e8eaed; color: var(--ui-text); }

.msg {
    margin-bottom: 10px;
    font-size: 13px;
    padding: 9px 10px;
    border-radius: 10px;
    display: none;
}

.msg.show { display: block; }
.msg.ok { background: #e6f4ea; color: var(--ui-success); }
.msg.err { background: #fce8e6; color: var(--ui-danger); }

.pagination-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.page-link,
.page-disabled,
.page-current {
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 13px;
    text-decoration: none;
}

.page-link { background: #f1f3f4; color: var(--ui-text); }
.page-link:hover { background: #e8eaed; }
.page-current { background: var(--ui-primary); color: #fff; }
.page-disabled { background: #f1f3f4; color: #9aa0a6; }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(32, 33, 36, 0.46);
    z-index: 1200;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.modal.show { display: flex; }

.modal-content {
    width: 100%;
    max-width: 760px;
    background: #fff;
    border-radius: 18px;
    padding: 16px;
    max-height: calc(100vh - 28px);
    overflow: auto;
    box-shadow: 0 12px 30px rgba(60, 64, 67, 0.28);
}

@media (max-width: 860px) {
    .billing-hero { flex-direction: column; }
    .billing-hero h2 { font-size: 24px; }
}

/* ════════════════════════════════════════════════════════════
   DARK MODE — ui-consistency overrides
   ════════════════════════════════════════════════════════════ */
[data-theme="dark"] {
    --ui-text:         #e8eaed;
    --ui-text-soft:    #9aa0a6;
    --ui-title:        #e8eaed;
    --ui-border:       #3c3e42;
    --ui-border-soft:  #3c3e42;
    --ui-surface:      #202124;
    --ui-surface-soft: #18191b;
    --ui-shadow-light: 0 1px 3px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.25);
}

/* Shell base text */
[data-theme="dark"] :where(.module-shell, .billing-shell, .ftth-shell,
    .mikrotik-shell, .paycash-shell, .config-shell) { color: #e8eaed; }

/* Billing hero */
[data-theme="dark"] .billing-hero {
    background: linear-gradient(135deg,#1a2540 0%,#202124 58%,#1a2030 100%);
    border-color: #3c3e42;
}
[data-theme="dark"] .billing-hero h2 { color: #e8eaed; }
[data-theme="dark"] .billing-hero p  { color: #9aa0a6; }

/* Hero action nav tabs */
[data-theme="dark"] .hero-actions a,
[data-theme="dark"] .hero-actions button {
    background: #2d2e31;
    border-color: #3c3e42;
    color: #bdc1c6;
}
[data-theme="dark"] .hero-actions a:hover,
[data-theme="dark"] .hero-actions button:hover {
    background: #3c3e42;
    color: #e8eaed;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
[data-theme="dark"] .hero-actions a.primary,
[data-theme="dark"] .hero-actions button.primary {
    background: #1a73e8;
    border-color: #1a73e8;
    color: #fff;
}

/* Stat cards — keep their vivid gradients in dark mode */

/* Generic cards, tables, modals in all module shells */
[data-theme="dark"] .billing-card,
[data-theme="dark"] .module-card      { background: #202124; border-color: #3c3e42; }

[data-theme="dark"] .billing-table th,
[data-theme="dark"] .module-table th  { background: #2d2e31; color: #9aa0a6; border-bottom-color: #3c3e42; }
[data-theme="dark"] .billing-table td,
[data-theme="dark"] .module-table td  { border-bottom-color: #2d2e31; color: #e8eaed; }
[data-theme="dark"] .billing-table tbody tr:hover,
[data-theme="dark"] .module-table tbody tr:hover { background: #2d3035; }

[data-theme="dark"] .chip-neutral     { background: #2d2e31; color: #9aa0a6; }
[data-theme="dark"] .chip-ok          { background: #14301e; color: #6ee7a4; }
[data-theme="dark"] .chip-warn        { background: #382e10; color: #fbbf24; }
[data-theme="dark"] .chip-bad         { background: #3a1414; color: #f87171; }

/* Modal overlay */
[data-theme="dark"] .modal-content    { background: #202124; border: 1px solid #3c3e42; }
[data-theme="dark"] .modal-title      { color: #e8eaed; }
[data-theme="dark"] .modal-sub        { color: #9aa0a6; }

/* Forms */
[data-theme="dark"] .form-grid label  { color: #9aa0a6; }
[data-theme="dark"] .form-grid input,
[data-theme="dark"] .form-grid select,
[data-theme="dark"] .form-grid textarea {
    background: #2d2e31;
    border-color: #3c3e42;
    color: #e8eaed;
}
[data-theme="dark"] .form-grid input::placeholder,
[data-theme="dark"] .form-grid textarea::placeholder { color: #5f6368; }

/* Generic buttons */
[data-theme="dark"] .gbtn.neutral     { background: #2d2e31; color: #e8eaed; }
[data-theme="dark"] .gbtn.primary     { background: #1a73e8; color: #fff; }
[data-theme="dark"] .gbtn.danger      { background: #3a1414; color: #f87171; }
