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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    min-height: 100vh;
    padding: 2rem;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

h1 {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 2rem;
    margin-bottom: 2rem;
    color: #fff;
}

form {
    margin-bottom: 1.5rem;
}

.form-row {
    display: flex;
    gap: 0.5rem;
}

input {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #e0e0e0;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: #666;
}

#url-input {
    flex: 2;
}

#code-input {
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

#token-input {
    width: 300px;
}

button {
    background: #fff;
    color: #0a0a0a;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

button:hover {
    opacity: 0.85;
}

.error {
    color: #ff4444;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

#create-result {
    color: #4caf50;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}

th, td {
    text-align: left;
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid #1a1a1a;
}

th {
    color: #888;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: #ccc;
}

th.sorted-asc::after {
    content: ' \25B2';
}

th.sorted-desc::after {
    content: ' \25BC';
}

td.code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 600;
}

td.code a {
    color: #e0e0e0;
    text-decoration: none;
}

td.code a:hover {
    text-decoration: underline;
}

td.dest {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #888;
    font-size: 0.85rem;
}

td.date {
    color: #666;
    font-size: 0.85rem;
}

td.hits {
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: #888;
}

td.actions {
    white-space: nowrap;
    position: relative;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    background: transparent;
    color: #888;
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    font-weight: 400;
    border: 1px solid #333;
    cursor: pointer;
}

.dropdown-toggle:hover {
    color: #e0e0e0;
    border-color: #666;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    overflow: hidden;
    z-index: 100;
    min-width: 150px;
}

.dropdown.open .dropdown-menu {
    display: flex;
    flex-direction: column;
}

.dropdown-menu button {
    background: transparent;
    color: #ccc;
    font-size: 0.85rem;
    padding: 0.5rem 0.8rem;
    font-weight: 400;
    border: none;
    border-radius: 0;
    text-align: left;
    cursor: pointer;
    width: 100%;
}

.dropdown-menu button:hover {
    background: #252525;
    color: #fff;
}

.dropdown-menu button.delete {
    color: #888;
}

.dropdown-menu button.delete:hover {
    background: #2a1515;
    color: #ff4444;
}

#empty-msg {
    color: #666;
    text-align: center;
    margin-top: 3rem;
}

#login-form {
    display: flex;
    gap: 0.5rem;
}

#analytics-section {
    margin-top: 3rem;
}

#analytics-section h2 {
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 1rem;
}

.analytics-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.analytics-controls select {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #e0e0e0;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

.analytics-controls button {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

#analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.analytics-card {
    background: #111;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 1rem;
}

.analytics-card h3 {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.8rem;
    font-weight: 500;
}

.analytics-card:first-child {
    grid-column: 1 / -1;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    font-size: 0.85rem;
}

.stat-label {
    color: #aaa;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 70%;
}

.stat-value {
    color: #fff;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 100px;
}

.chart-bar {
    flex: 1;
    background: #fff;
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    position: relative;
}

.chart-bar:hover::after {
    content: attr(data-label);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
}

.analytics-empty {
    color: #444;
    font-size: 0.85rem;
    text-align: center;
    padding: 1rem;
}

@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
    }

    #token-input {
        width: 100%;
    }
}
