/* ============================================================
   NetHive Internal Apps — Global Stylesheet
   Theme: Dark Navy (#0d2b55) + White, Professional
   ============================================================ */

:root {
    --primary: #0d2b55;
    --primary-dark: #081d3a;
    --primary-mid: #1a4a8a;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --surface: #f4f7fc;
    --surface-2: #e8eef8;
    --border: #dde3ef;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --white: #ffffff;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --warning: #d97706;
    --shadow: 0 2px 12px rgba(13, 43, 85, 0.12);
    --shadow-lg: 0 8px 32px rgba(13, 43, 85, 0.16);
    --radius: 8px;
    --radius-sm: 5px;
    --radius-lg: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.18s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

/* ── Top Navigation ─────────────────────────────────────────── */
.topnav {
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topnav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.topnav-logo {
    height: 38px;
    width: auto;
    filter: brightness(0) invert(1);
}

.topnav-logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.3px;
}

.topnav-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
}

.topnav-tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.topnav-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    text-decoration: none;
}

.topnav-tab.active {
    background: rgba(255, 255, 255, 0.18);
    color: var(--white);
}

.topnav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

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

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

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent);
    color: var(--white);
}

.btn-outline-light {
    background: transparent;
    color: var(--white);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--white);
}

.btn-ghost {
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    border-color: transparent;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-sm {
    padding: 6px 13px;
    font-size: 0.82rem;
}

.btn-lg {
    padding: 12px 26px;
    font-size: 1rem;
}

.btn[disabled],
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
    flex: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.4px;
}

.page-header p {
    color: var(--text-muted);
    margin-top: 4px;
    font-size: 0.95rem;
}

.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2,
.card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary);
}

.card-body {
    padding: 24px;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.form-section-header {
    background: var(--primary);
    color: var(--white);
    padding: 14px 24px;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.form-section-header span {
    opacity: 0.7;
    font-weight: 400;
    font-size: 0.8rem;
    margin-left: 8px;
    text-transform: none;
}

.form-section-body {
    padding: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

.form-full {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.2px;
}

.form-group label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-control[readonly],
.form-control[disabled] {
    background: var(--surface);
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-control.is-invalid {
    border-color: var(--danger);
}

textarea.form-control {
    resize: vertical;
    min-height: 90px;
}

select.form-control {
    cursor: pointer;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 3px;
}

/* ── Tax Calculation Box ────────────────────────────────────── */
.tax-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    border-radius: var(--radius-lg);
    padding: 24px;
    color: var(--white);
}

.tax-box-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    margin-bottom: 16px;
    font-weight: 600;
}

.tax-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.95rem;
}

.tax-row:last-child {
    border-bottom: none;
}

.tax-row.total-row {
    font-size: 1.2rem;
    font-weight: 700;
    padding-top: 14px;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    border-bottom: none;
    margin-top: 4px;
}

.tax-row .label {
    opacity: 0.85;
}

.tax-row .value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

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

thead {
    background: var(--primary);
}

thead th {
    color: var(--white);
    padding: 13px 16px;
    text-align: left;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--surface);
}

tbody td {
    padding: 13px 16px;
    font-size: 0.92rem;
    vertical-align: middle;
}

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

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent);
}

.badge-success {
    background: rgba(22, 163, 74, 0.12);
    color: var(--success);
}

.badge-warning {
    background: rgba(217, 119, 6, 0.12);
    color: var(--warning);
}

/* ── Search Bar ─────────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-bar .form-control {
    max-width: 360px;
    flex: 1;
}

/* ── Flash Messages ─────────────────────────────────────────── */
.flash {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.4s ease;
}

.flash-success {
    background: rgba(22, 163, 74, 0.1);
    color: var(--success);
    border-left: 4px solid var(--success);
}

.flash-error {
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
    border-left: 4px solid var(--danger);
}

.flash-info {
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent);
    border-left: 4px solid var(--accent);
}

/* ── Summary Cards ──────────────────────────────────────────── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.summary-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    border-left: 5px solid var(--primary);
}

.summary-card.accent {
    border-left-color: var(--accent);
}

.summary-card.success {
    border-left-color: var(--success);
}

.summary-card-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.summary-card-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

.summary-card.accent .summary-card-value {
    color: var(--accent);
}

.summary-card.success .summary-card-value {
    color: var(--success);
}

/* ── Dashboard App Tiles ────────────────────────────────────── */
.dashboard-welcome {
    text-align: center;
    padding: 40px 24px 32px;
}

.dashboard-welcome h1 {
    font-size: 2rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 8px;
}

.dashboard-welcome p {
    color: var(--text-muted);
    font-size: 1.05rem;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
    padding: 8px 0 40px;
}

.app-tile {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    text-decoration: none;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.app-tile:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    text-decoration: none;
}

.app-tile-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.app-tile-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
}

.app-tile-desc {
    font-size: 0.87rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.app-tile-open {
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Login Page ─────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 60%, #2a5298 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo img {
    max-height: 50px;
    filter: none;
}

.login-logo img.logo-dark {
    filter: brightness(0) saturate(100%) invert(13%) sepia(48%) saturate(1200%) hue-rotate(200deg);
}

.login-logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 8px;
}

.login-box h2 {
    font-size: 1.4rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 6px;
    text-align: center;
}

.login-box p.sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

.login-box .form-group {
    margin-bottom: 18px;
}

.login-btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 1rem;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    max-width: 440px;
    width: 100%;
    text-align: center;
}

.modal-box h3 {
    font-size: 1.15rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 12px;
}

.modal-box p {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-bottom: 24px;
}

.modal-box p strong {
    color: var(--text);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.breadcrumb a {
    color: var(--accent);
}

.breadcrumb-sep {
    color: var(--border);
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
    background: var(--primary-dark);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    margin-top: auto;
}

.site-footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Filter Bar ─────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar select.form-control {
    width: auto;
    min-width: 140px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .main-content {
        padding: 20px 16px;
    }

    .topnav-inner {
        padding: 0 16px;
    }

    .topnav-tabs {
        display: none;
    }

    .form-grid,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }

    .form-full {
        grid-column: 1;
    }

    .page-header h1 {
        font-size: 1.4rem;
    }

    .login-box {
        padding: 32px 24px;
    }
}

@media (max-width: 480px) {
    .td-actions {
        flex-direction: column;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }
}