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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.5;
}

.container {
    max-width: 800px;
    margin: 40px auto;
    padding: 0 16px;
}

/* Top bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    flex-wrap: wrap;
    gap: 8px;
}

.top-bar h1 {
    font-size: 24px;
}

.top-links {
    display: flex;
    gap: 12px;
    align-items: center;
}

.admin-link {
    font-size: 13px;
    color: #4a90d9;
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid #4a90d9;
    border-radius: 6px;
    transition: background 0.2s;
}

.admin-link:hover {
    background: #eef4fd;
}

.admin-link--red {
    color: #e74c3c;
    border-color: #e74c3c;
}

.admin-link--red:hover {
    background: #fdeaea;
}

.subtitle {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 24px;
}

/* Calculator */
.calculator {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.search-block {
    margin-bottom: 16px;
    position: relative;
}

.search-block label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}

.search-block input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.search-block input[type="text"]:focus {
    border-color: #4a90d9;
}

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.search-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
}

.search-item:hover {
    background: #f0f4ff;
}

.no-results {
    padding: 10px 14px;
    color: #999;
    font-size: 14px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}

.selected-product {
    padding: 10px 14px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    min-height: 44px;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: #4a90d9;
}

button, .btn {
    background: #4a90d9;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}

button:hover:not(:disabled), .btn:hover {
    background: #357abd;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-small {
    background: #4a90d9;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    width: auto;
    display: inline-block;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-small:hover {
    background: #357abd;
}

.btn-danger {
    background: #e74c3c;
}

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

.btn-edit {
    background: #f0ad4e;
}

.btn-edit:hover {
    background: #ec971f;
}

.result {
    margin-top: 16px;
    padding: 16px;
    background: #e8f5e9;
    border-radius: 8px;
    border: 1px solid #c8e6c9;
}

.result h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: #2e7d32;
}

.result p {
    font-size: 16px;
    line-height: 1.7;
}

/* History */
.history {
    margin-top: 32px;
    background: #fff;
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.history h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

#history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#history-table th {
    text-align: left;
    padding: 8px 6px;
    border-bottom: 2px solid #e0e0e0;
    color: #666;
    font-size: 13px;
}

#history-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #f0f0f0;
}

#history-table tbody tr:hover {
    background: #f8f9fa;
}

.empty-msg {
    color: #999;
    font-size: 14px;
    text-align: center;
    padding: 16px;
}

/* Admin login */
.admin-login {
    max-width: 380px;
    margin: 60px auto;
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.admin-login h1 {
    font-size: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: #4a90d9;
    font-size: 14px;
}

/* Alert */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: #fdeaea;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

/* Admin panel */
.admin-actions {
    margin-bottom: 16px;
}

.admin-search {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}

.admin-search input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.admin-search input[type="text"]:focus {
    border-color: #4a90d9;
}

.admin-search button {
    width: auto;
    padding: 10px 20px;
    font-size: 14px;
}

.admin-table-wrap {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 2px solid #e0e0e0;
    color: #666;
    font-size: 13px;
    white-space: nowrap;
}

.admin-table td {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.admin-table tbody tr:hover {
    background: #f8f9fa;
}

.admin-table .actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #333;
}

.modal-content h2 {
    font-size: 18px;
    margin-bottom: 20px;
}

.modal-content .form-group {
    margin-bottom: 16px;
}

.modal-content button[type="submit"] {
    margin-top: 8px;
}
