/* UNO Billing Platform - Enterprise Style */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: #111827;
    background: #F9FAFB;
    min-height: 100vh;
}

/* Top Navigation */
.topnav {
    background: #1B4F8A;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 50px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.topnav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topnav-brand {
    font-weight: 600;
    font-size: 17px;
    letter-spacing: 0.5px;
}

.topnav-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.3);
}

.topnav-subtitle {
    font-size: 13px;
    opacity: 0.8;
}

.topnav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topnav-org {
    font-size: 13px;
    opacity: 0.85;
}

.topnav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
}

/* App Layout */
.app-layout {
    display: flex;
    margin-top: 50px;
    min-height: calc(100vh - 50px);
}

/* Sidebar */
/* One variable drives both the sidebar width and the content offset, so
   collapsing is a single change rather than two that can drift apart. */
:root { --sidebar-w: 210px; }
body.sidebar-collapsed { --sidebar-w: 60px; }

.sidebar {
    width: var(--sidebar-w);
    background: #FAFBFC;
    border-right: 1px solid #E5E7EB;
    position: fixed;
    top: 50px;
    bottom: 0;
    left: 0;
    /* A column with a scrolling middle. The version badge used to be
       position:absolute inside this scroll box, so it rode up with the
       content instead of staying at the bottom. */
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: width 0.18s ease;
}
.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0;
}
.sidebar-footer {
    flex: 0 0 auto;
    border-top: 1px solid #E5E7EB;
    padding: 10px 12px;
    background: #FAFBFC;
}

/* The collapse flap, sitting on the sidebar's right edge like PeerEdge's. */
.sidebar-toggle {
    position: absolute;
    top: 14px;
    right: -11px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid #E5E7EB;
    background: #fff;
    color: #6B7280;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    z-index: 20;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: background 0.15s, color 0.15s;
}
.sidebar-toggle:hover { background: #F3F4F6; color: #111827; }
.sidebar-toggle svg { transition: transform 0.18s ease; }
body.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

/* Collapsed: icons only. Labels are hidden rather than removed so nothing
   reflows and the icons stay put. */
/* Labels are bare text nodes next to the icon, not wrapped elements, so they
   can't be hidden by selector. Zeroing the font size collapses them and any
   whitespace; the icons carry explicit width/height so they're unaffected.
   The unread-feedback badge gets its size back so it still shows. */
body.sidebar-collapsed .sidebar-item { justify-content: center; padding: 9px 0; margin: 1px 6px; gap: 0; font-size: 0; }
body.sidebar-collapsed .sidebar-item span { font-size: 9px; margin-left: 0 !important; position: absolute; transform: translate(12px, -10px); }
body.sidebar-collapsed .sidebar-item { position: relative; }
body.sidebar-collapsed .sidebar-section-label { height: 1px; overflow: hidden; padding: 0; margin: 14px 12px; background: #E5E7EB; color: transparent; }
body.sidebar-collapsed .sidebar-footer { padding: 10px 6px; }
body.sidebar-collapsed .sidebar-footer .version-text { display: none; }
body.sidebar-collapsed .sidebar-footer a { justify-content: center; padding: 6px 0; }

.sidebar-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6B7280;
    padding: 8px 20px 6px;
    font-weight: 600;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    margin: 1px 8px;
    border-radius: 6px;
    color: #4B5563;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-item:hover {
    background: #F3F4F6;
    color: #111827;
}

.sidebar-item.active {
    background: #EBF4FF;
    color: #1B4F8A;
    font-weight: 500;
}

.sidebar-item svg {
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    transition: margin-left 0.18s ease;
    min-width: 0;
    padding: 28px 36px;
    background: white;
    min-height: calc(100vh - 50px);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.page-subtitle {
    font-size: 13px;
    color: #6B7280;
    margin-top: 2px;
}

/* Step Indicator */
.stepper {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: #FAFBFC;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
    margin-bottom: 28px;
}

.step {
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.step-number.active {
    background: #1B4F8A;
    color: white;
}

.step-number.completed {
    background: #059669;
    color: white;
}

.step-number.pending {
    background: white;
    border: 1.5px solid #D1D5DB;
    color: #9CA3AF;
}

.step-label {
    font-size: 13px;
    color: #6B7280;
}

.step-label.active {
    color: #1B4F8A;
    font-weight: 500;
}

.step-label.completed {
    color: #059669;
    font-weight: 500;
}

.step-connector {
    flex: 1;
    height: 1px;
    background: #D1D5DB;
    margin: 0 16px;
}

.step-connector.completed {
    background: #059669;
}

/* Cards */
.card {
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

/* Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.metric-card {
    padding: 14px 16px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: white;
}

.metric-label {
    font-size: 12px;
    color: #6B7280;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.metric-value {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.metric-check {
    color: #059669;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #E5E7EB;
    font-weight: 600;
    color: #374151;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #F3F4F6;
    color: #4B5563;
}

.data-table tr:hover td {
    background: #F9FAFB;
}

.data-table .amount {
    text-align: right;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-draft { background: #F3F4F6; color: #6B7280; }
.badge-in_progress { background: #EBF4FF; color: #1B4F8A; }
.badge-review { background: #FEF3C7; color: #92400E; }
.badge-approved { background: #D1FAE5; color: #065F46; }
.badge-finalized { background: #D1FAE5; color: #065F46; }
.badge-closed { background: #065F46; color: #FFFFFF; }
.badge-rejected { background: #FEE2E2; color: #991B1B; }
.badge-imported { background: #E0E7FF; color: #3730A3; }
.badge-archived { background: #F3F4F6; color: #6B7280; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: #1B4F8A;
    color: white;
}

.btn-primary:hover {
    background: #164070;
}

.btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #D1D5DB;
}

.btn-secondary:hover {
    background: #F9FAFB;
}

.btn-danger {
    background: white;
    color: #DC2626;
    border: 1px solid #FCA5A5;
}

.btn-danger:hover {
    background: #FEF2F2;
}

.btn-success {
    background: #059669;
    color: white;
}

.btn-success:hover {
    background: #047857;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.form-input, .form-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-size: 13px;
    color: #111827;
    background: white;
    transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: #1B4F8A;
    box-shadow: 0 0 0 3px rgba(27, 79, 138, 0.1);
}

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

/* Flash Messages */
.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flash-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.flash-error { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.flash-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.flash-info { background: #EBF4FF; color: #1B4F8A; border: 1px solid #BFDBFE; }

.flash-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #6B7280;
}

.empty-state svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 16px;
}

/* Summary Box */
.summary-box {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.summary-row.total {
    border-top: 1px solid #E5E7EB;
    margin-top: 8px;
    padding-top: 10px;
    font-weight: 600;
    font-size: 15px;
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #E5E7EB;
}

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.filters .form-select {
    width: auto;
    min-width: 160px;
}
