*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif;
    background: #f0f4f8;
    color: #1a202c;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.page-header,
.stats-header {
    text-align: center;
    margin-bottom: 32px;
}

.page-header h1,
.stats-header h1 {
    margin: 0 0 8px;
    font-size: 1.75rem;
}

.page-header p,
.stats-header .meta {
    margin: 0;
    color: #64748b;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card h2 {
    margin: 0 0 16px;
    font-size: 1.15rem;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.btn {
    display: inline-block;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    background: #e2e8f0;
    color: #1a202c;
    transition: background 0.15s;
}

.btn:hover {
    background: #cbd5e1;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-warning {
    background: #fef3c7;
    color: #92400e;
}

.btn-warning:hover {
    background: #fde68a;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.top-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.form-grid {
    display: grid;
    gap: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
textarea.copy-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}

textarea.copy-input {
    resize: vertical;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.85rem;
}

.login-card {
    max-width: 400px;
    margin: 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.stat-card.highlight {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    margin-top: 4px;
    font-size: 0.9rem;
    opacity: 0.85;
}

.chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-grid-6 {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tab {
    padding: 8px 16px;
    background: #fff;
    border-radius: 8px;
    text-decoration: none;
    color: #475569;
    font-size: 0.9rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: all 0.15s;
}

.tab:hover {
    background: #e2e8f0;
    color: #1a202c;
}

.tab.active {
    background: #2563eb;
    color: #fff;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table .nowrap {
    white-space: nowrap;
}

.data-table .ua-cell {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #64748b;
    font-size: 0.85rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.page-info {
    color: #64748b;
    font-size: 0.9rem;
}

.table-note {
    text-align: right;
    color: #94a3b8;
    font-size: 0.85rem;
    margin: 12px 0 0;
}

.chart-row {
    display: grid;
    grid-template-columns: 120px 1fr 50px;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.chart-row.today .chart-date {
    font-weight: 700;
    color: #2563eb;
}

.chart-bar-wrap {
    background: #e2e8f0;
    border-radius: 4px;
    height: 20px;
    overflow: hidden;
}

.chart-bar {
    background: #3b82f6;
    height: 100%;
    border-radius: 4px;
    min-width: 2px;
    transition: width 0.3s;
}

.chart-row.today .chart-bar {
    background: #2563eb;
}

.chart-date {
    color: #64748b;
}

.chart-value {
    text-align: right;
    font-weight: 600;
}

.counter-item {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}

.counter-item:last-child {
    margin-bottom: 0;
}

.counter-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.counter-head h3 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    background: #e2e8f0;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-right: 6px;
}

.badge-green {
    background: #dcfce7;
    color: #166534;
}

.counter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-form {
    display: inline;
}

.snippet-block {
    margin-bottom: 12px;
}

.snippet-block label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 6px;
}

.copy-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.copy-row .copy-input {
    flex: 1;
}

.empty {
    color: #94a3b8;
    text-align: center;
    padding: 24px 0;
}

.footer-note {
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

.info-card ol {
    margin: 0;
    padding-left: 20px;
}

.info-card li {
    margin-bottom: 8px;
}

code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.error-card {
    text-align: center;
}

.ip-detected {
    font-size: 1.5rem;
    padding: 8px 12px;
}

.muted {
    color: #94a3b8;
}

@media (max-width: 600px) {
    .chart-row {
        grid-template-columns: 90px 1fr 40px;
        gap: 8px;
        font-size: 0.8rem;
    }

    .counter-head {
        flex-direction: column;
    }
}
