:root {
    /* Color Palette (Dark Theme, gentle on eyes) */
    --bg-color: #121418;
    --surface-color: #1e2228;
    --surface-hover: #2a2e35;
    --text-primary: #e0e4e8;
    --text-secondary: #9aa0a6;
    --accent-color: #4da6ff; /* Soft blue */
    --accent-hover: #3388dd;
    --danger-color: #ff5c5c;
    --danger-hover: #dd4040;
    --border-color: #30363d;
    --input-bg: #0d1117;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* Layout */
.container {
    max-width: 95%;
    margin: 0 auto;
    padding: 20px;
}

/* Navbar */
nav {
    background-color: var(--surface-color);
    padding: 15px 30px;
    display: flex;
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

nav a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

nav a:hover, nav a.active {
    background-color: var(--surface-hover);
    color: var(--accent-color);
}

/* Cards */
.card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Typography */
h1, h2, h3, h4 {
    color: var(--text-primary);
    font-weight: 600;
    margin-top: 0;
}

p {
    color: var(--text-secondary);
}

/* Forms & Inputs */
input[type="text"], input[type="password"], textarea, select {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
    font-family: var(--font-family);
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 12px;
}

input[type="text"]:focus, input[type="password"]:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-lg {
    font-size: 1.15em;
    padding: 12px 18px;
}

.form-md {
    font-size: 1.05em;
    padding: 10px 14px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.inline-label {
    display: inline-block;
    margin-bottom: 0;
    margin-right: 15px;
}

/* Buttons */
button {
    background-color: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button:hover {
    background-color: var(--accent-hover);
}

button:active {
    transform: scale(0.98);
}

button.danger {
    background-color: var(--danger-color);
}

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

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    margin-bottom: 20px;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--surface-hover);
    color: var(--text-secondary);
    font-weight: 600;
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.03);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}
.tab-button {
    background: none;
    color: var(--text-secondary);
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    border-radius: 0;
}
.tab-button:hover {
    color: var(--text-primary);
    background: none;
}
.tab-button.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* Messages */
.msg { color: #66cc8a; background: rgba(102, 204, 138, 0.1); padding: 10px; border-radius: 6px; margin-bottom: 15px; border-left: 4px solid #66cc8a;}
.error { color: #ff5c5c; background: rgba(255, 92, 92, 0.1); padding: 10px; border-radius: 6px; margin-bottom: 15px; border-left: 4px solid #ff5c5c;}

/* Company Info Tab specific */
.metrics-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 20px;
    margin: 20px 0;
    overflow-x: auto;
}
.metric-card {
    flex: 1 1 0;
    min-width: 150px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}
.metric-label {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 5px;
}
.metric-value {
    color: var(--text-primary);
    font-size: 1.8em;
    font-weight: 600;
}
.charts-wrapper {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}
@media (max-width: 992px) {
    .charts-wrapper {
        grid-template-columns: 1fr;
    }
}
details.company-desc {
    background: var(--input-bg);
    border-radius: 6px;
    padding: 10px 15px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}
details.company-desc summary {
    cursor: pointer;
    font-weight: bold;
    color: var(--text-primary);
    outline: none;
}
details.company-desc p {
    margin-top: 10px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Utilities */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    width: 100%;
    max-width: 400px;
}
.text-center { text-align: center; }
.mb-4 { margin-bottom: 20px; }
.mt-4 { margin-top: 20px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-4 { gap: 15px; }
.gap-lg { gap: 25px; } /* Larger gap for dropdowns */
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-auto { width: auto !important; }
.d-flex { display: flex; }
.align-center { align-items: center; }

/* Custom search controls wrapper */
.search-controls-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
}

.search-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    align-items: center;
}

/* Bootstrap-like Utilities */
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.ms-1 { margin-left: 4px; }
.ms-2 { margin-left: 8px; }
.ms-3 { margin-left: 16px; }
.ms-auto { margin-left: auto; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.p-2 { padding: 8px; }
.p-3 { padding: 16px; }
.flex-grow-1 { flex-grow: 1; }

/* RESPONSIVE DESIGN */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.table-responsive table {
    min-width: 600px; /* Force scroll if screen is too small */
    white-space: nowrap;
}

/* Base Nav styling for wrapping */
.nav-container {
    flex-wrap: wrap;
}

/* Default Mobile Rules (applied when screen <= 768px and NOT force-pc) */
@media (max-width: 768px) {
    :root:not(.force-pc) .hide-on-mobile { display: none !important; }
    
    :root:not(.force-pc) .stack-on-mobile {
        flex-direction: column;
        align-items: stretch !important;
        height: auto !important;
    }
    :root:not(.force-pc) .stack-on-mobile > * {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-bottom: 10px;
    }
    :root:not(.force-pc) .nav-container {
        flex-direction: column;
        align-items: stretch;
        padding: 10px 15px;
    }
    :root:not(.force-pc) .nav-links {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        gap: 10px;
        margin-top: 10px;
        justify-content: flex-start;
        padding-bottom: 5px;
    }
    :root:not(.force-pc) .nav-spacer { display: none; }
    :root:not(.force-pc) .nav-actions {
        margin-top: 15px;
        justify-content: space-between;
        width: 100%;
        border-top: 1px solid var(--border-color);
        padding-top: 10px;
    }
    
    :root:not(.force-pc) .search-controls-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    :root:not(.force-pc) .search-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    :root:not(.force-pc) .search-controls select,
    :root:not(.force-pc) .search-controls label {
        width: 100% !important;
    }
}

/* Force Mobile View (applied when force-mobile class is present) */
:root.force-mobile {
    /* Limit the overall width to simulate a phone, or just apply mobile layout to full screen. 
       Usually it's better to just apply the mobile layout rules regardless of screen width. */
}
:root.force-mobile .hide-on-mobile { display: none !important; }

:root.force-mobile .stack-on-mobile {
    flex-direction: column;
    align-items: stretch !important;
    height: auto !important;
}
:root.force-mobile .stack-on-mobile > * {
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 10px;
}

:root.force-mobile .nav-container {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 15px;
}
:root.force-mobile .nav-links {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 10px;
    margin-top: 10px;
    justify-content: flex-start;
    padding-bottom: 5px;
}
:root.force-mobile .nav-spacer { display: none; }
:root.force-mobile .nav-actions {
    margin-top: 15px;
    justify-content: space-between;
    width: 100%;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}

:root.force-mobile .search-controls-wrapper {
    flex-direction: column;
    align-items: stretch;
}
:root.force-mobile .search-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}
:root.force-mobile .search-controls select,
:root.force-mobile .search-controls label {
    width: 100% !important;
}
:root.force-mobile .charts-wrapper {
    grid-template-columns: 1fr;
}

/* Force PC View (applied when force-pc class is present) */
:root.force-pc body {
    min-width: 1024px;
}
:root.force-pc .container {
    max-width: 1200px;
}
